- virtual ~Comm();
-
- static xbt::signal<void(Actor const&)> on_sender_start;
- static xbt::signal<void(Actor const&)> on_receiver_start;
- static xbt::signal<void(Actor const&)> on_completion;
-
- /*! take a vector s4u::CommPtr and return when one of them is finished.
- * The return value is the rank of the first finished CommPtr. */
- static int wait_any(std::vector<CommPtr> * comms) { return wait_any_for(comms, -1); }
- /*! Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.*/
- static int wait_any_for(std::vector<CommPtr>* comms_in, double timeout);
-
- /*! take a vector s4u::CommPtr and return when all of them is finished. */
- static void wait_all(std::vector<CommPtr>* comms);
- /*! take a vector s4u::CommPtr and return the rank of the first finished one (or -1 if none is done). */
- static int test_any(std::vector<CommPtr> * comms);
-
- Comm* start() override;
- Comm* wait() override;
- Comm* wait_for(double timeout) override;
- Comm* cancel() override;
- bool test() override;
-
- /** Start the comm, and ignore its result. It can be completely forgotten after that. */
- Comm* detach();
- /** Start the comm, and ignore its result. It can be completely forgotten after that. */
- Comm* detach(void (*clean_function)(void*))
- {
- clean_fun_ = clean_function;
- return detach();
- }
-
- /** Sets the maximal communication rate (in byte/sec). Must be done before start */
- CommPtr set_rate(double rate);
+ static void on_send_cb(const std::function<void(Comm const&)>& cb) { on_send.connect(cb); }
+ static void on_recv_cb(const std::function<void(Comm const&)>& cb) { on_recv.connect(cb); }
+ static void on_start_cb(const std::function<void(Comm const&)>& cb) { on_start.connect(cb); }
+ static void on_completion_cb(const std::function<void(Activity const&)>& cb) { on_completion.connect(cb); }
+ /* More callbacks */
+ CommPtr set_copy_data_callback(void (*callback)(kernel::activity::CommImpl*, void*, size_t));
+ static void copy_buffer_callback(kernel::activity::CommImpl*, void*, size_t);
+ static void copy_pointer_callback(kernel::activity::CommImpl*, void*, size_t);
+
+ ~Comm() override;
+
+ static void send(kernel::actor::ActorImpl* sender, const Mailbox* mbox, double task_size, double rate, void* src_buff,
+ size_t src_buff_size, bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
+ double timeout);
+ static void recv(kernel::actor::ActorImpl* receiver, const Mailbox* mbox, void* dst_buff, size_t* dst_buff_size,
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
+ double timeout, double rate);
+
+ /* "One-sided" communications. This way of communicating bypasses the mailbox and actors mechanism. It creates a
+ * communication (vetoabled, asynchronous, or synchronous) directly between two hosts. There is really no limit on
+ * the hosts involved. In particular, the actor creating such a communication does not have to be on one of the
+ * involved hosts! Enjoy the comfort of the simulator :)
+ */
+ static CommPtr sendto_init(); /* Source and Destination hosts have to be set before the communication can start */
+ static CommPtr sendto_init(Host* from, Host* to);
+ static CommPtr sendto_async(Host* from, Host* to, uint64_t simulated_size_in_bytes);
+ static void sendto(Host* from, Host* to, uint64_t simulated_size_in_bytes);
+
+ CommPtr set_source(Host* from);
+ Host* get_source() const;
+ CommPtr set_destination(Host* to);
+ Host* get_destination() const;
+
+ /* Mailbox-based communications */
+ CommPtr set_mailbox(Mailbox* mailbox);
+ /** Retrieve the mailbox on which this comm acts */
+ Mailbox* get_mailbox() const { return mailbox_; }