1 /* Copyright (c) 2023. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_S4U_MESS_HPP
7 #define SIMGRID_S4U_MESS_HPP
9 #include <simgrid/forward.h>
10 #include <simgrid/s4u/Activity.hpp>
15 namespace simgrid::s4u {
17 class XBT_PUBLIC Mess : public Activity_T<Mess> {
19 friend MessageQueue; // Factory of messages
20 friend kernel::activity::MessImpl;
22 MessageQueue* queue_ = nullptr;
23 void* payload_ = nullptr;
24 size_t dst_buff_size_ = 0;
25 void* dst_buff_ = nullptr;
28 Mess* do_start() override;
30 static xbt::signal<void(Mess const&)> on_send;
31 xbt::signal<void(Mess const&)> on_this_send;
32 static xbt::signal<void(Mess const&)> on_recv;
33 xbt::signal<void(Mess const&)> on_this_recv;
35 /* These ensure that the on_completion signals are really thrown */
36 void fire_on_completion_for_real() const { Activity_T<Mess>::fire_on_completion(); }
37 void fire_on_this_completion_for_real() const { Activity_T<Mess>::fire_on_this_completion(); }
41 Mess(Mess const&) = delete;
42 Mess& operator=(Mess const&) = delete;
45 MessPtr set_queue(MessageQueue* queue);
46 MessageQueue* get_queue() const { return queue_; }
48 /** Retrieve the payload associated to the communication. You can only do that once the comm is (gracefully)
50 void* get_payload() const { return payload_; }
51 MessPtr set_payload(void* data);
52 MessPtr set_dst_data(void** buff, size_t size);
53 Actor* get_sender() const;
54 Actor* get_receiver() const;
56 bool is_assigned() const override { return true; };
58 Mess* wait_for(double timeout) override;
60 kernel::actor::ActorImpl* sender_ = nullptr;
61 kernel::actor::ActorImpl* receiver_ = nullptr;
63 } // namespace simgrid::s4u
65 #endif /* SIMGRID_S4U_MESS_HPP */