Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
_SIMIX_cond_wait becomes ConditionVariable::wait
[simgrid.git] / src / kernel / activity / CommImpl.hpp
1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_KERNEL_ACTIVITY_COMM_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_COMM_HPP
8
9 #include "src/kernel/activity/ActivityImpl.hpp"
10 #include "src/simix/ActorImpl.hpp"
11 #include "surf/surf.hpp"
12
13
14 namespace simgrid {
15 namespace kernel {
16 namespace activity {
17
18 class XBT_PUBLIC CommImpl : public ActivityImpl {
19   ~CommImpl() override;
20
21 public:
22   enum class Type { SEND = 0, RECEIVE, READY, DONE };
23
24   explicit CommImpl(Type type);
25   void start();
26   void copy_data();
27   void suspend() override;
28   void resume() override;
29   void post() override;
30   void cancel();
31   double remains();
32   void cleanupSurf(); // FIXME: make me protected
33
34   CommImpl::Type type;          /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
35   smx_mailbox_t mbox = nullptr; /* Rendez-vous where the comm is queued */
36
37 #if SIMGRID_HAVE_MC
38   smx_mailbox_t mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
39                                      (comm.mbox set to nullptr when the communication is removed from the mailbox
40                                      (used as garbage collector)) */
41 #endif
42   bool detached = false; /* If detached or not */
43
44   void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */
45   int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*) =
46       nullptr; /* Filter function used by the other side. It is used when
47 looking if a given communication matches my needs. For that, myself must match the
48 expectations of the other side, too. See  */
49   void (*copy_data_fun)(smx_activity_t, void*, size_t) = nullptr;
50
51   /* Surf action data */
52   resource::Action* surf_action_ = nullptr; /* The Surf communication action encapsulated */
53   resource::Action* src_timeout_ = nullptr; /* Surf's actions to instrument the timeouts */
54   resource::Action* dst_timeout_ = nullptr; /* Surf's actions to instrument the timeouts */
55   actor::ActorImplPtr src_actor_ = nullptr;
56   actor::ActorImplPtr dst_actor_ = nullptr;
57   double rate_                   = 0.0;
58   double task_size_              = 0.0;
59
60   /* Data to be transfered */
61   void* src_buff_        = nullptr;
62   void* dst_buff_        = nullptr;
63   size_t src_buff_size_  = 0;
64   size_t* dst_buff_size_ = nullptr;
65   bool copied           = false; /* whether the data were already copied */
66
67   void* src_data_ = nullptr; /* User data associated to the communication */
68   void* dst_data_ = nullptr;
69 };
70 }
71 }
72 } // namespace simgrid::kernel::activity
73
74 #endif