From: Arnaud Giersch Date: Tue, 12 Mar 2019 09:53:17 +0000 (+0100) Subject: MailboxPtr looks like a smart pointer, but it's not. Kill it. X-Git-Tag: v3_22~113 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/691d7c891da0352a6fa38507a482b287c7e086de MailboxPtr looks like a smart pointer, but it's not. Kill it. --- diff --git a/docs/source/Tutorial_Algorithms.rst b/docs/source/Tutorial_Algorithms.rst index e12657f691..feb034a023 100644 --- a/docs/source/Tutorial_Algorithms.rst +++ b/docs/source/Tutorial_Algorithms.rst @@ -461,7 +461,7 @@ messages to all workers based on their number, for example as follows: for (int i = 0; i < tasks_count; i++) { std::string worker_rank = std::to_string(i % workers_count); std::string mailbox_name = std::string("worker-") + worker_rank; - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); mailbox->put(...); diff --git a/docs/source/app_s4u.rst b/docs/source/app_s4u.rst index 3f3aaec09c..3c8c2064d9 100644 --- a/docs/source/app_s4u.rst +++ b/docs/source/app_s4u.rst @@ -507,8 +507,6 @@ s4u::Mailbox Please also refer to the :ref:`full doc on s4u::Mailbox `. -.. doxygentypedef:: MailboxPtr - .. doxygenclass:: simgrid::s4u::Mailbox :members: :protected-members: diff --git a/docs/source/tuto_s4u/master-workers-lab1.cpp b/docs/source/tuto_s4u/master-workers-lab1.cpp index dc97047869..9a40c14f41 100644 --- a/docs/source/tuto_s4u/master-workers-lab1.cpp +++ b/docs/source/tuto_s4u/master-workers-lab1.cpp @@ -31,7 +31,7 @@ static void master(std::vector args) /* - Select a worker in a round-robin way */ std::string worker_rank = std::to_string(i % workers_count); std::string mailbox_name = std::string("worker-") + worker_rank; - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); /* - Send the computation cost to that worker */ XBT_INFO("Sending task %d of %ld to mailbox '%s'", i, tasks_count, mailbox->get_cname()); @@ -42,7 +42,7 @@ static void master(std::vector args) for (int i = 0; i < workers_count; i++) { /* The workers stop when receiving a negative compute_cost */ std::string mailbox_name = std::string("worker-") + std::to_string(i); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); mailbox->put(new double(-1.0), 0); } @@ -54,7 +54,7 @@ static void worker(std::vector args) long id = std::stol(args[1]); const std::string mailbox_name = std::string("worker-") + std::to_string(id); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); double compute_cost; do { diff --git a/docs/source/tuto_s4u/master-workers-lab2.cpp b/docs/source/tuto_s4u/master-workers-lab2.cpp index f9e17d322e..9380eb2049 100644 --- a/docs/source/tuto_s4u/master-workers-lab2.cpp +++ b/docs/source/tuto_s4u/master-workers-lab2.cpp @@ -19,7 +19,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_masterworker, "Messages specific for this e static void worker() { const std::string mailbox_name = std::string("worker-") + std::to_string(simgrid::s4u::this_actor::get_pid()); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); double compute_cost; do { @@ -56,7 +56,7 @@ static void master(std::vector args) /* - Select a worker in a round-robin way */ aid_t worker_pid = actors.at(i % actors.size())->get_pid(); std::string mailbox_name = std::string("worker-") + std::to_string(worker_pid); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); /* - Send the computation cost to that worker */ XBT_INFO("Sending task %d of %ld to mailbox '%s'", i, tasks_count, mailbox->get_cname()); @@ -67,7 +67,7 @@ static void master(std::vector args) for (unsigned long i = 0; i < actors.size(); i++) { /* The workers stop when receiving a negative compute_cost */ std::string mailbox_name = std::string("worker-") + std::to_string(actors.at(i)->get_pid()); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); mailbox->put(new double(-1.0), 0); } diff --git a/docs/source/tuto_s4u/master-workers-lab3.cpp b/docs/source/tuto_s4u/master-workers-lab3.cpp index 6d657826fd..2f439be518 100644 --- a/docs/source/tuto_s4u/master-workers-lab3.cpp +++ b/docs/source/tuto_s4u/master-workers-lab3.cpp @@ -19,7 +19,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_masterworker, "Messages specific for this e static void worker() { const std::string mailbox_name = std::string("worker-") + std::to_string(simgrid::s4u::this_actor::get_pid()); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); while (true) { // Master forcefully kills the workers by the end of the simulation double* msg = static_cast(mailbox->get()); @@ -54,7 +54,7 @@ static void master(std::vector args) /* - Select a worker in a round-robin way */ aid_t worker_pid = actors.at(task_id % actors.size())->get_pid(); std::string mailbox_name = std::string("worker-") + std::to_string(worker_pid); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); /* - Send the computation cost to that worker */ if (task_id % 100 == 0) diff --git a/docs/source/tuto_s4u/master-workers-lab4.cpp b/docs/source/tuto_s4u/master-workers-lab4.cpp index 3861d79314..819fd4ea49 100644 --- a/docs/source/tuto_s4u/master-workers-lab4.cpp +++ b/docs/source/tuto_s4u/master-workers-lab4.cpp @@ -19,7 +19,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_masterworker, "Messages specific for this e static void worker(std::string category) { const std::string mailbox_name = std::string("worker-") + std::to_string(simgrid::s4u::this_actor::get_pid()); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); while (true) { // Master forcefully kills the workers by the end of the simulation double* msg = static_cast(mailbox->get()); @@ -60,7 +60,7 @@ static void master(std::vector args) /* - Select a worker in a round-robin way */ aid_t worker_pid = actors.at(task_id % actors.size())->get_pid(); std::string mailbox_name = std::string("worker-") + std::to_string(worker_pid); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); /* - Send the computation cost to that worker */ XBT_DEBUG("Sending task %d to mailbox '%s'", task_id, mailbox->get_cname()); diff --git a/examples/s4u/actor-create/s4u-actor-create.cpp b/examples/s4u/actor-create/s4u-actor-create.cpp index 43cd620a96..b587f42136 100644 --- a/examples/s4u/actor-create/s4u-actor-create.cpp +++ b/examples/s4u/actor-create/s4u-actor-create.cpp @@ -29,7 +29,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_create, "The logging channel used in this */ static void receiver(const std::string& mailbox_name) { - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name); XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->get_cname()); @@ -47,8 +47,8 @@ static void receiver(const std::string& mailbox_name) static int forwarder(int argc, char** argv) { xbt_assert(argc >= 3, "Actor forwarder requires 2 parameters, but got only %d", argc - 1); - simgrid::s4u::MailboxPtr in = simgrid::s4u::Mailbox::by_name(argv[1]); - simgrid::s4u::MailboxPtr out = simgrid::s4u::Mailbox::by_name(argv[2]); + simgrid::s4u::Mailbox* in = simgrid::s4u::Mailbox::by_name(argv[1]); + simgrid::s4u::Mailbox* out = simgrid::s4u::Mailbox::by_name(argv[2]); std::string* msg = static_cast(in->get()); XBT_INFO("Forward '%s'.", msg->c_str()); out->put(msg, msg->size()); @@ -79,7 +79,7 @@ public: void operator()() /* This is the main code of the actor */ { XBT_INFO("Hello s4u, I have something to send"); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mbox); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mbox); mailbox->put(new std::string(msg), msg.size()); XBT_INFO("I'm done. See you."); diff --git a/examples/s4u/app-bittorrent/s4u-bittorrent.hpp b/examples/s4u/app-bittorrent/s4u-bittorrent.hpp index 69759e6ea4..19551d01a7 100644 --- a/examples/s4u/app-bittorrent/s4u-bittorrent.hpp +++ b/examples/s4u/app-bittorrent/s4u-bittorrent.hpp @@ -56,16 +56,16 @@ class Message { public: e_message_type type; int peer_id; - simgrid::s4u::MailboxPtr return_mailbox; + simgrid::s4u::Mailbox* return_mailbox; unsigned int bitfield = 0U; int piece = 0; int block_index = 0; int block_length = 0; - Message(e_message_type type, int peer_id, simgrid::s4u::MailboxPtr return_mailbox) + Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox) : type(type), peer_id(peer_id), return_mailbox(return_mailbox){}; - Message(e_message_type type, int peer_id, unsigned int bitfield, simgrid::s4u::MailboxPtr return_mailbox) + Message(e_message_type type, int peer_id, unsigned int bitfield, simgrid::s4u::Mailbox* return_mailbox) : type(type), peer_id(peer_id), return_mailbox(return_mailbox), bitfield(bitfield){}; - Message(e_message_type type, int peer_id, simgrid::s4u::MailboxPtr return_mailbox, int piece, int block_index, + Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece, int block_index, int block_length) : type(type) , peer_id(peer_id) @@ -73,7 +73,7 @@ public: , piece(piece) , block_index(block_index) , block_length(block_length){}; - Message(e_message_type type, int peer_id, simgrid::s4u::MailboxPtr return_mailbox, int piece) + Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece) : type(type), peer_id(peer_id), return_mailbox(return_mailbox), piece(piece){}; ~Message() = default; }; diff --git a/examples/s4u/app-bittorrent/s4u-peer.cpp b/examples/s4u/app-bittorrent/s4u-peer.cpp index d36aae49e9..f28d40b67a 100644 --- a/examples/s4u/app-bittorrent/s4u-peer.cpp +++ b/examples/s4u/app-bittorrent/s4u-peer.cpp @@ -85,7 +85,7 @@ void Peer::operator()() bool Peer::getPeersFromTracker() { - simgrid::s4u::MailboxPtr tracker_mailbox = simgrid::s4u::Mailbox::by_name(TRACKER_MAILBOX); + simgrid::s4u::Mailbox* tracker_mailbox = simgrid::s4u::Mailbox::by_name(TRACKER_MAILBOX); // Build the task to send to the tracker TrackerQuery* peer_request = new TrackerQuery(id, mailbox_); try { @@ -121,14 +121,14 @@ void Peer::sendHandshakeToAllPeers() } } -void Peer::sendMessage(simgrid::s4u::MailboxPtr mailbox, e_message_type type, uint64_t size) +void Peer::sendMessage(simgrid::s4u::Mailbox* mailbox, e_message_type type, uint64_t size) { const char* type_names[6] = {"HANDSHAKE", "CHOKE", "UNCHOKE", "INTERESTED", "NOTINTERESTED", "CANCEL"}; XBT_DEBUG("Sending %s to %s", type_names[type], mailbox->get_cname()); mailbox->put_init(new Message(type, id, bitfield_, mailbox_), size)->detach(); } -void Peer::sendBitfield(simgrid::s4u::MailboxPtr mailbox) +void Peer::sendBitfield(simgrid::s4u::Mailbox* mailbox) { XBT_DEBUG("Sending a BITFIELD to %s", mailbox->get_cname()); mailbox @@ -137,7 +137,7 @@ void Peer::sendBitfield(simgrid::s4u::MailboxPtr mailbox) ->detach(); } -void Peer::sendPiece(simgrid::s4u::MailboxPtr mailbox, unsigned int piece, int block_index, int block_length) +void Peer::sendPiece(simgrid::s4u::Mailbox* mailbox, unsigned int piece, int block_index, int block_length) { xbt_assert(not hasNotPiece(piece), "Tried to send a unavailable piece."); XBT_DEBUG("Sending the PIECE %u (%d,%d) to %s", piece, block_index, block_length, mailbox->get_cname()); diff --git a/examples/s4u/app-bittorrent/s4u-peer.hpp b/examples/s4u/app-bittorrent/s4u-peer.hpp index d77c4ba566..2d9eb6ad6c 100644 --- a/examples/s4u/app-bittorrent/s4u-peer.hpp +++ b/examples/s4u/app-bittorrent/s4u-peer.hpp @@ -13,7 +13,7 @@ class Connection { public: int id; // Peer id - simgrid::s4u::MailboxPtr mailbox_; + simgrid::s4u::Mailbox* mailbox_; unsigned int bitfield = 0U; // Fields // int messages_count; double peer_speed = 0; @@ -34,7 +34,7 @@ class Peer { int id; double deadline; RngStream stream; - simgrid::s4u::MailboxPtr mailbox_; + simgrid::s4u::Mailbox* mailbox_; std::unordered_map connected_peers; std::set active_peers; // active peers list @@ -77,9 +77,9 @@ public: void requestNewPieceTo(Connection* remote_peer); bool getPeersFromTracker(); - void sendMessage(simgrid::s4u::MailboxPtr mailbox, e_message_type type, uint64_t size); - void sendBitfield(simgrid::s4u::MailboxPtr mailbox); - void sendPiece(simgrid::s4u::MailboxPtr mailbox, unsigned int piece, int block_index, int block_length); + void sendMessage(simgrid::s4u::Mailbox* mailbox, e_message_type type, uint64_t size); + void sendBitfield(simgrid::s4u::Mailbox* mailbox); + void sendPiece(simgrid::s4u::Mailbox* mailbox, unsigned int piece, int block_index, int block_length); void sendHandshakeToAllPeers(); void sendHaveToAllPeers(unsigned int piece); void sendRequestTo(Connection* remote_peer, unsigned int piece); diff --git a/examples/s4u/app-bittorrent/s4u-tracker.hpp b/examples/s4u/app-bittorrent/s4u-tracker.hpp index 27c025e584..4755919f08 100644 --- a/examples/s4u/app-bittorrent/s4u-tracker.hpp +++ b/examples/s4u/app-bittorrent/s4u-tracker.hpp @@ -12,13 +12,14 @@ class TrackerQuery { int peer_id; // peer id - simgrid::s4u::MailboxPtr return_mailbox; + simgrid::s4u::Mailbox* return_mailbox; + public: - explicit TrackerQuery(int peer_id, simgrid::s4u::MailboxPtr return_mailbox) + explicit TrackerQuery(int peer_id, simgrid::s4u::Mailbox* return_mailbox) : peer_id(peer_id), return_mailbox(return_mailbox){}; ~TrackerQuery() = default; int getPeerId() { return peer_id; } - simgrid::s4u::MailboxPtr getReturnMailbox() { return return_mailbox; } + simgrid::s4u::Mailbox* getReturnMailbox() { return return_mailbox; } }; class TrackerAnswer { @@ -36,7 +37,7 @@ public: class Tracker { double deadline; RngStream stream; - simgrid::s4u::MailboxPtr mailbox; + simgrid::s4u::Mailbox* mailbox; std::set known_peers; public: diff --git a/examples/s4u/app-chainsend/s4u-app-chainsend.cpp b/examples/s4u/app-chainsend/s4u-app-chainsend.cpp index 39ee01def8..dcf8e3c97e 100644 --- a/examples/s4u/app-chainsend/s4u-app-chainsend.cpp +++ b/examples/s4u/app-chainsend/s4u-app-chainsend.cpp @@ -14,10 +14,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_chainsend, "Messages specific for chainsend"); class ChainMessage { public: - simgrid::s4u::MailboxPtr prev_ = nullptr; - simgrid::s4u::MailboxPtr next_ = nullptr; + simgrid::s4u::Mailbox* prev_ = nullptr; + simgrid::s4u::Mailbox* next_ = nullptr; unsigned int num_pieces = 0; - explicit ChainMessage(simgrid::s4u::MailboxPtr prev, simgrid::s4u::MailboxPtr next, const unsigned int num_pieces) + explicit ChainMessage(simgrid::s4u::Mailbox* prev, simgrid::s4u::Mailbox* next, const unsigned int num_pieces) : prev_(prev), next_(next), num_pieces(num_pieces) { } @@ -32,9 +32,9 @@ public: class Peer { public: - simgrid::s4u::MailboxPtr prev = nullptr; - simgrid::s4u::MailboxPtr next = nullptr; - simgrid::s4u::MailboxPtr me = nullptr; + simgrid::s4u::Mailbox* prev = nullptr; + simgrid::s4u::Mailbox* next = nullptr; + simgrid::s4u::Mailbox* me = nullptr; std::vector pending_recvs; std::vector pending_sends; @@ -90,20 +90,20 @@ public: class Broadcaster { public: - simgrid::s4u::MailboxPtr first = nullptr; - std::vector mailboxes; + simgrid::s4u::Mailbox* first = nullptr; + std::vector mailboxes; unsigned int piece_count; void buildChain() { auto cur = mailboxes.begin(); - simgrid::s4u::MailboxPtr prev = nullptr; - simgrid::s4u::MailboxPtr last = nullptr; + simgrid::s4u::Mailbox* prev = nullptr; + simgrid::s4u::Mailbox* last = nullptr; /* Build the chain if there's at least one peer */ if (cur != mailboxes.end()) { /* init: prev=NULL, host=current cur, next=next cur */ - simgrid::s4u::MailboxPtr next = *cur; + simgrid::s4u::Mailbox* next = *cur; first = next; /* This iterator iterates one step ahead: cur is current iterated element, but is actually next in the chain */ @@ -111,7 +111,7 @@ public: /* following steps: prev=last, host=next, next=cur */ ++cur; prev = last; - simgrid::s4u::MailboxPtr current_mailbox = next; + simgrid::s4u::Mailbox* current_mailbox = next; if (cur != mailboxes.end()) next = *cur; else diff --git a/examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp b/examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp index c320b67946..a91f203ad8 100644 --- a/examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp +++ b/examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp @@ -15,7 +15,7 @@ class Master { long tasks_count = 0; double compute_cost = 0; double communicate_cost = 0; - std::vector workers; + std::vector workers; public: explicit Master(std::vector args) @@ -35,7 +35,7 @@ public: { for (int i = 0; i < tasks_count; i++) { /* For each task to be executed: */ /* - Select a worker in a round-robin way */ - simgrid::s4u::MailboxPtr mailbox = workers[i % workers.size()]; + simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()]; /* - Send the computation amount to the worker */ if (tasks_count < 10000 || (tasks_count < 100000 && i % 10000 == 0) || i % 100000 == 0) @@ -46,14 +46,14 @@ public: XBT_INFO("All tasks have been dispatched. Request all workers to stop."); for (unsigned int i = 0; i < workers.size(); i++) { /* The workers stop when receiving a negative compute_cost */ - simgrid::s4u::MailboxPtr mailbox = workers[i % workers.size()]; + simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()]; mailbox->put(new double(-1.0), 0); } } }; class Worker { - simgrid::s4u::MailboxPtr mailbox = nullptr; + simgrid::s4u::Mailbox* mailbox = nullptr; public: explicit Worker(std::vector args) diff --git a/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp b/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp index fefc90c278..40780fc0ff 100644 --- a/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp +++ b/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp @@ -19,7 +19,7 @@ static void master(std::vector args) long tasks_count = std::stol(args[1]); double compute_cost = std::stod(args[2]); double communication_cost = std::stod(args[3]); - std::vector workers; + std::vector workers; for (unsigned int i = 4; i < args.size(); i++) workers.push_back(simgrid::s4u::Mailbox::by_name(args[i])); @@ -27,7 +27,7 @@ static void master(std::vector args) for (int i = 0; i < tasks_count; i++) { /* For each task to be executed: */ /* - Select a worker in a round-robin way */ - simgrid::s4u::MailboxPtr mailbox = workers[i % workers.size()]; + simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()]; /* - Send the computation cost to that worker */ XBT_INFO("Sending task %d of %ld to mailbox '%s'", i, tasks_count, mailbox->get_cname()); @@ -37,7 +37,7 @@ static void master(std::vector args) XBT_INFO("All tasks have been dispatched. Request all workers to stop."); for (unsigned int i = 0; i < workers.size(); i++) { /* The workers stop when receiving a negative compute_cost */ - simgrid::s4u::MailboxPtr mailbox = workers[i % workers.size()]; + simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()]; mailbox->put(new double(-1.0), 0); } @@ -50,7 +50,7 @@ static void worker(std::vector args) xbt_assert(args.size() == 1, "The worker expects no argument"); simgrid::s4u::Host* my_host = simgrid::s4u::this_actor::get_host(); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(my_host->get_name()); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(my_host->get_name()); double compute_cost; do { diff --git a/examples/s4u/app-pingpong/s4u-app-pingpong.cpp b/examples/s4u/app-pingpong/s4u-app-pingpong.cpp index c9bb2e8bfb..019d6b25c0 100644 --- a/examples/s4u/app-pingpong/s4u-app-pingpong.cpp +++ b/examples/s4u/app-pingpong/s4u-app-pingpong.cpp @@ -7,7 +7,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_pingpong, "Messages specific for this s4u example"); -static void pinger(simgrid::s4u::MailboxPtr mailbox_in, simgrid::s4u::MailboxPtr mailbox_out) +static void pinger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mailbox_out) { XBT_INFO("Ping from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str()); @@ -25,7 +25,7 @@ static void pinger(simgrid::s4u::MailboxPtr mailbox_in, simgrid::s4u::MailboxPtr delete sender_time; } -static void ponger(simgrid::s4u::MailboxPtr mailbox_in, simgrid::s4u::MailboxPtr mailbox_out) +static void ponger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mailbox_out) { XBT_INFO("Pong from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str()); @@ -49,8 +49,8 @@ int main(int argc, char* argv[]) simgrid::s4u::Engine e(&argc, argv); e.load_platform(argv[1]); - simgrid::s4u::MailboxPtr mb1 = simgrid::s4u::Mailbox::by_name("Mailbox 1"); - simgrid::s4u::MailboxPtr mb2 = simgrid::s4u::Mailbox::by_name("Mailbox 2"); + simgrid::s4u::Mailbox* mb1 = simgrid::s4u::Mailbox::by_name("Mailbox 1"); + simgrid::s4u::Mailbox* mb2 = simgrid::s4u::Mailbox::by_name("Mailbox 2"); simgrid::s4u::Actor::create("pinger", simgrid::s4u::Host::by_name("Tremblay"), pinger, mb1, mb2); simgrid::s4u::Actor::create("ponger", simgrid::s4u::Host::by_name("Jupiter"), ponger, mb2, mb1); diff --git a/examples/s4u/app-token-ring/s4u-app-token-ring.cpp b/examples/s4u/app-token-ring/s4u-app-token-ring.cpp index 3a2a02d4b9..27741143cc 100644 --- a/examples/s4u/app-token-ring/s4u-app-token-ring.cpp +++ b/examples/s4u/app-token-ring/s4u-app-token-ring.cpp @@ -13,8 +13,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_token_ring, "Messages specific for this s4u class RelayRunner { size_t task_comm_size = 1000000; /* The token is 1MB long*/ - simgrid::s4u::MailboxPtr my_mailbox; - simgrid::s4u::MailboxPtr neighbor_mailbox; + simgrid::s4u::Mailbox* my_mailbox; + simgrid::s4u::Mailbox* neighbor_mailbox; unsigned int rank = 0; public: diff --git a/examples/s4u/async-ready/s4u-async-ready.cpp b/examples/s4u/async-ready/s4u-async-ready.cpp index f796acec33..17367532a1 100644 --- a/examples/s4u/async-ready/s4u-async-ready.cpp +++ b/examples/s4u/async-ready/s4u-async-ready.cpp @@ -34,7 +34,7 @@ static int peer(int argc, char** argv) long peers_count = std::stod(argv[4]); /* - number of peers */ /* Set myself as the persistent receiver of my mailbox so that messages start flowing to me as soon as they are put into it */ - simgrid::s4u::MailboxPtr my_mbox = simgrid::s4u::Mailbox::by_name(std::string("peer-") + std::to_string(my_id)); + simgrid::s4u::Mailbox* my_mbox = simgrid::s4u::Mailbox::by_name(std::string("peer-") + std::to_string(my_id)); my_mbox->set_receiver(simgrid::s4u::Actor::self()); std::vector pending_comms; @@ -44,7 +44,7 @@ static int peer(int argc, char** argv) for (int peer_id = 0; peer_id < peers_count; peer_id++) { if (peer_id != my_id) { std::string mboxName = std::string("peer-") + std::to_string(peer_id); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(mboxName); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName); std::string msgName = std::string("Message ") + std::to_string(i) + std::string(" from peer ") + std::to_string(my_id); std::string* payload = new std::string(msgName); // copy the data we send: // 'msgName' is not a stable storage location @@ -59,7 +59,7 @@ static int peer(int argc, char** argv) for (int peer_id = 0; peer_id < peers_count; peer_id++) { if (peer_id != my_id) { std::string mboxName = std::string("peer-") + std::to_string(peer_id); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(mboxName); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName); std::string* payload = new std::string("finalize"); // Make a copy of the data we will send pending_comms.push_back(mbox->put_async(payload, msg_size)); XBT_INFO("Send 'finalize' to 'peer-%d'", peer_id); diff --git a/examples/s4u/async-wait/s4u-async-wait.cpp b/examples/s4u/async-wait/s4u-async-wait.cpp index 0d377bb7cf..2898edb6b4 100644 --- a/examples/s4u/async-wait/s4u-async-wait.cpp +++ b/examples/s4u/async-wait/s4u-async-wait.cpp @@ -29,7 +29,7 @@ static int sender(int argc, char** argv) std::vector pending_comms; /* Make a vector of the mailboxes to use */ - std::vector mboxes; + std::vector mboxes; for (int i = 0; i < receivers_count; i++) mboxes.push_back(simgrid::s4u::Mailbox::by_name(std::string("receiver-") + std::to_string(i))); @@ -70,7 +70,7 @@ static int sender(int argc, char** argv) static int receiver(int argc, char** argv) { xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(std::string("receiver-") + argv[1]); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(std::string("receiver-") + argv[1]); XBT_INFO("Wait for my first message"); for (bool cont = true; cont;) { diff --git a/examples/s4u/async-waitall/s4u-async-waitall.cpp b/examples/s4u/async-waitall/s4u-async-waitall.cpp index fafc4ca7e6..e3d83cfd9e 100644 --- a/examples/s4u/async-waitall/s4u-async-waitall.cpp +++ b/examples/s4u/async-waitall/s4u-async-waitall.cpp @@ -39,7 +39,7 @@ public: std::vector pending_comms; /* Make a vector of the mailboxes to use */ - std::vector mboxes; + std::vector mboxes; for (int i = 0; i < receivers_count; i++) mboxes.push_back(simgrid::s4u::Mailbox::by_name(std::string("receiver-") + std::to_string(i))); // sphinx-doc: init-end @@ -76,7 +76,7 @@ public: /* Receiver actor expects 1 argument: its ID */ class Receiver { - simgrid::s4u::MailboxPtr mbox; + simgrid::s4u::Mailbox* mbox; public: explicit Receiver(std::vector args) diff --git a/examples/s4u/async-waitany/s4u-async-waitany.cpp b/examples/s4u/async-waitany/s4u-async-waitany.cpp index 9b6a62e409..4d3b1fab49 100644 --- a/examples/s4u/async-waitany/s4u-async-waitany.cpp +++ b/examples/s4u/async-waitany/s4u-async-waitany.cpp @@ -43,7 +43,7 @@ public: std::vector pending_comms; /* Make a vector of the mailboxes to use */ - std::vector mboxes; + std::vector mboxes; for (int i = 0; i < receivers_count; i++) mboxes.push_back(simgrid::s4u::Mailbox::by_name(std::string("receiver-") + std::to_string(i))); @@ -89,7 +89,7 @@ public: /* Receiver actor expects 1 argument: its ID */ class Receiver { - simgrid::s4u::MailboxPtr mbox; + simgrid::s4u::Mailbox* mbox; public: explicit Receiver(std::vector args) diff --git a/examples/s4u/async-waituntil/s4u-async-waituntil.cpp b/examples/s4u/async-waituntil/s4u-async-waituntil.cpp index 296ef1df02..f741f5a583 100644 --- a/examples/s4u/async-waituntil/s4u-async-waituntil.cpp +++ b/examples/s4u/async-waituntil/s4u-async-waituntil.cpp @@ -30,7 +30,7 @@ static int sender(int argc, char** argv) for (int i = 0; i < messages_count; i++) { std::string mboxName = std::string("receiver-") + std::to_string(i % receivers_count); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(mboxName); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName); std::string msgName = std::string("Message ") + std::to_string(i); std::string* payload = new std::string(msgName); // copy the data we send: // 'msgName' is not a stable storage location @@ -44,7 +44,7 @@ static int sender(int argc, char** argv) /* Start sending messages to let the workers know that they should stop */ for (int i = 0; i < receivers_count; i++) { std::string mboxName = std::string("receiver-") + std::to_string(i % receivers_count); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(mboxName); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName); std::string* payload = new std::string("finalize"); // Make a copy of the data we will send simgrid::s4u::CommPtr comm = mbox->put_async(payload, 0); @@ -68,7 +68,7 @@ static int sender(int argc, char** argv) static int receiver(int argc, char** argv) { xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(std::string("receiver-") + argv[1]); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(std::string("receiver-") + argv[1]); XBT_INFO("Wait for my first message"); for (bool cont = true; cont;) { diff --git a/examples/s4u/cloud-simple/s4u-cloud-simple.cpp b/examples/s4u/cloud-simple/s4u-cloud-simple.cpp index b6113ab818..08a341ab83 100644 --- a/examples/s4u/cloud-simple/s4u-cloud-simple.cpp +++ b/examples/s4u/cloud-simple/s4u-cloud-simple.cpp @@ -32,7 +32,7 @@ struct s_payload { static void communication_tx_fun(std::vector args) { - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(args.at(0)); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(args.at(0)); s_payload* payload = new s_payload; payload->tx_actor_name = simgrid::s4u::Actor::self()->get_cname(); payload->tx_host = simgrid::s4u::this_actor::get_host(); @@ -45,7 +45,7 @@ static void communication_rx_fun(std::vector args) { const char* actor_name = simgrid::s4u::Actor::self()->get_cname(); const char* host_name = simgrid::s4u::this_actor::get_host()->get_cname(); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(args.at(0)); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(args.at(0)); struct s_payload* payload = static_cast(mbox->get()); double clock_end = simgrid::s4u::Engine::get_clock(); diff --git a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp index 52a0d55189..f69461b58b 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp +++ b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp @@ -212,8 +212,8 @@ void Node::checkPredecessor() if (pred_id_ == -1) return; - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_)); - simgrid::s4u::MailboxPtr return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_is_alive"); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_)); + simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_is_alive"); ChordMessage* message = new ChordMessage(PREDECESSOR_ALIVE); message->request_id = pred_id_; @@ -252,8 +252,8 @@ int Node::remoteGetPredecessor(int ask_to) { int predecessor_id = -1; void* data = nullptr; - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to)); - simgrid::s4u::MailboxPtr return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_pred"); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to)); + simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_pred"); ChordMessage* message = new ChordMessage(GET_PREDECESSOR); message->request_id = id_; @@ -324,8 +324,8 @@ int Node::remoteFindSuccessor(int ask_to, int id) { int successor = -1; void* data = nullptr; - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to)); - simgrid::s4u::MailboxPtr return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ"); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to)); + simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ"); ChordMessage* message = new ChordMessage(FIND_SUCCESSOR); message->request_id = id_; @@ -379,7 +379,7 @@ void Node::remoteNotify(int notify_id, int predecessor_candidate_id) // send a "Notify" request to notify_id XBT_DEBUG("Sending a 'Notify' request to %d", notify_id); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(notify_id)); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(notify_id)); mailbox->put_init(message, 10)->detach(ChordMessage::destroy); } @@ -426,7 +426,7 @@ void Node::handleMessage(ChordMessage* message) int closest = closestPrecedingFinger(message->request_id); XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d", message->request_id, closest); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(closest)); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(closest)); mailbox->put_init(message, 10)->detach(ChordMessage::destroy); } break; diff --git a/examples/s4u/dht-chord/s4u-dht-chord.hpp b/examples/s4u/dht-chord/s4u-dht-chord.hpp index 7db25b19da..c071fe25d4 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord.hpp +++ b/examples/s4u/dht-chord/s4u-dht-chord.hpp @@ -61,7 +61,7 @@ public: int request_id = -1; // id (used by some types of messages) int request_finger = 1; // finger parameter (used by some types of messages) int answer_id = -1; // answer (used by some types of messages) - simgrid::s4u::MailboxPtr answer_to; // mailbox to send an answer to (if any) + simgrid::s4u::Mailbox* answer_to; // mailbox to send an answer to (if any) explicit ChordMessage(e_message_type_t type) : type(type), issuer_host_name(simgrid::s4u::this_actor::get_host()->get_name()) @@ -80,7 +80,7 @@ class Node { bool joined = false; int id_; // my id int pred_id_ = -1; // predecessor id - simgrid::s4u::MailboxPtr mailbox_; // my mailbox + simgrid::s4u::Mailbox* mailbox_; // my mailbox int* fingers_; // finger table,(fingers[0] is my successor) int next_finger_to_fix; // index of the next finger to fix in fix_fingers() RngStream stream; diff --git a/examples/s4u/dht-kademlia/message.hpp b/examples/s4u/dht-kademlia/message.hpp index 9e32c59dac..c1b643437e 100644 --- a/examples/s4u/dht-kademlia/message.hpp +++ b/examples/s4u/dht-kademlia/message.hpp @@ -18,11 +18,11 @@ public: unsigned int sender_id_ = 0; // Id of the guy who sent the task unsigned int destination_id_ = 0; // Id we are trying to find, if needed. Answer* answer_ = nullptr; // Answer to the request made, if needed. - simgrid::s4u::MailboxPtr answer_to_ = nullptr; // mailbox to send the answer to (if not an answer). + simgrid::s4u::Mailbox* answer_to_ = nullptr; // mailbox to send the answer to (if not an answer). std::string issuer_host_name_; // used for logging - explicit Message(unsigned int sender_id, unsigned int destination_id, Answer* answer, - simgrid::s4u::MailboxPtr mailbox, const char* hostname) + explicit Message(unsigned int sender_id, unsigned int destination_id, Answer* answer, simgrid::s4u::Mailbox* mailbox, + const char* hostname) : sender_id_(sender_id) , destination_id_(destination_id) , answer_(answer) @@ -30,7 +30,7 @@ public: , issuer_host_name_(hostname) { } - explicit Message(unsigned int sender_id, unsigned int destination_id, simgrid::s4u::MailboxPtr mailbox, + explicit Message(unsigned int sender_id, unsigned int destination_id, simgrid::s4u::Mailbox* mailbox, const char* hostname) : Message(sender_id, destination_id, nullptr, mailbox, hostname) { diff --git a/examples/s4u/dht-kademlia/node.cpp b/examples/s4u/dht-kademlia/node.cpp index 7956dedcbc..2f7a7567d3 100644 --- a/examples/s4u/dht-kademlia/node.cpp +++ b/examples/s4u/dht-kademlia/node.cpp @@ -33,7 +33,7 @@ bool Node::join(unsigned int known_id) /* First step: Send a "FIND_NODE" request to the node we know */ sendFindNode(known_id, id_); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_)); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_)); do { if (receive_comm == nullptr) receive_comm = mailbox->get_async(&received_msg); @@ -79,7 +79,7 @@ bool Node::join(unsigned int known_id) void Node::sendFindNode(unsigned int id, unsigned int destination) { /* Gets the mailbox to send to */ - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id)); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id)); /* Build the task */ Message* msg = new Message(id_, destination, simgrid::s4u::Mailbox::by_name(std::to_string(id_)), simgrid::s4u::Host::current()->get_cname()); @@ -200,7 +200,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats) steps++; double time_beginreceive = simgrid::s4u::Engine::get_clock(); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_)); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_)); do { if (receive_comm == nullptr) receive_comm = mailbox->get_async(&received_msg); diff --git a/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp b/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp index 29d8d2b10b..c6c8fc1bf4 100644 --- a/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp +++ b/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp @@ -44,7 +44,7 @@ static int node(int argc, char* argv[]) XBT_VERB("Main loop start"); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(node->getId())); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(node->getId())); while (simgrid::s4u::Engine::get_clock() < deadline) { if (node->receive_comm == nullptr) diff --git a/examples/s4u/energy-link/s4u-energy-link.cpp b/examples/s4u/energy-link/s4u-energy-link.cpp index aba6b01798..e765771ca5 100644 --- a/examples/s4u/energy-link/s4u-energy-link.cpp +++ b/examples/s4u/energy-link/s4u-energy-link.cpp @@ -22,7 +22,7 @@ static void sender(std::vector args) double comm_size = std::stod(args.at(1)); XBT_INFO("Send %.0f bytes, in %d flows", comm_size, flow_amount); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::string("message")); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::string("message")); /* Sleep a while before starting the example */ simgrid::s4u::this_actor::sleep_for(10); @@ -48,7 +48,7 @@ static void receiver(std::vector args) XBT_INFO("Receiving %d flows ...", flow_amount); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::string("message")); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::string("message")); if (flow_amount == 1) { void* res = mailbox->get(); diff --git a/examples/s4u/platform-failures/s4u-platform-failures.cpp b/examples/s4u/platform-failures/s4u-platform-failures.cpp index cd949f8edb..f0150d8d94 100644 --- a/examples/s4u/platform-failures/s4u-platform-failures.cpp +++ b/examples/s4u/platform-failures/s4u-platform-failures.cpp @@ -25,7 +25,7 @@ static int master(int argc, char* argv[]) { xbt_assert(argc == 5, "Expecting one parameter"); - simgrid::s4u::MailboxPtr mailbox; + simgrid::s4u::Mailbox* mailbox; long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); double comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); double comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); @@ -84,7 +84,7 @@ static int worker(int argc, char* argv[]) { xbt_assert(argc == 2, "Expecting one parameter"); long id = xbt_str_parse_int(argv[1], "Invalid argument %s"); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(id)); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(id)); double* payload = nullptr; double comp_size = -1; while (1) { diff --git a/examples/s4u/replay-comm/s4u-replay-comm.cpp b/examples/s4u/replay-comm/s4u-replay-comm.cpp index 491c3a8e30..2b73587ac3 100644 --- a/examples/s4u/replay-comm/s4u-replay-comm.cpp +++ b/examples/s4u/replay-comm/s4u-replay-comm.cpp @@ -55,8 +55,7 @@ public: double size = std::stod(action[3]); std::string* payload = new std::string(action[3]); double clock = simgrid::s4u::Engine::get_clock(); - simgrid::s4u::MailboxPtr to = - simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_name() + "_" + action[2]); + simgrid::s4u::Mailbox* to = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_name() + "_" + action[2]); ACT_DEBUG("Entering Send: %s (size: %g) -- Actor %s on mailbox %s", NAME.c_str(), size, simgrid::s4u::this_actor::get_cname(), to->get_cname()); to->put(payload, size); @@ -68,7 +67,7 @@ public: static void recv(simgrid::xbt::ReplayAction& action) { double clock = simgrid::s4u::Engine::get_clock(); - simgrid::s4u::MailboxPtr from = + simgrid::s4u::Mailbox* from = simgrid::s4u::Mailbox::by_name(std::string(action[2]) + "_" + simgrid::s4u::this_actor::get_name()); ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME.c_str(), simgrid::s4u::this_actor::get_cname(), diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index fa40a14903..e92b3a7d0c 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -62,10 +62,6 @@ XBT_PUBLIC void intrusive_ptr_add_ref(Io* i); class Link; class Mailbox; -/** Smart pointer to a simgrid::s4u::Mailbox */ -typedef boost::intrusive_ptr MailboxPtr; -XBT_PUBLIC void intrusive_ptr_release(Mailbox* m); -XBT_PUBLIC void intrusive_ptr_add_ref(Mailbox* m); class Mutex; XBT_PUBLIC void intrusive_ptr_release(Mutex* m); diff --git a/include/simgrid/s4u/Comm.hpp b/include/simgrid/s4u/Comm.hpp index d858df952b..cdcd9f0742 100644 --- a/include/simgrid/s4u/Comm.hpp +++ b/include/simgrid/s4u/Comm.hpp @@ -19,7 +19,7 @@ namespace s4u { * Represents all asynchronous communications, that you can test or wait onto. */ class XBT_PUBLIC Comm : public Activity { - MailboxPtr mailbox_ = nullptr; + Mailbox* mailbox_ = nullptr; kernel::actor::ActorImpl* sender_ = nullptr; kernel::actor::ActorImpl* receiver_ = nullptr; double rate_ = -1; @@ -112,7 +112,7 @@ public: CommPtr set_dst_data(void** buff, size_t size); /** Retrieve the mailbox on which this comm acts */ - MailboxPtr get_mailbox(); + Mailbox* get_mailbox(); /** Retrieve the size of the received data. Not to be mixed with @ref Activity::set_remaining() */ size_t get_dst_data_size(); @@ -148,7 +148,7 @@ public: { return get_dst_data_size(); } - XBT_ATTRIB_DEPRECATED_v323("Please use Comm::get_mailbox()") MailboxPtr getMailbox() { return get_mailbox(); } + XBT_ATTRIB_DEPRECATED_v323("Please use Comm::get_mailbox()") Mailbox* getMailbox() { return get_mailbox(); } #endif }; } // namespace s4u diff --git a/include/simgrid/s4u/Mailbox.hpp b/include/simgrid/s4u/Mailbox.hpp index 5be4b24d13..3f3475acef 100644 --- a/include/simgrid/s4u/Mailbox.hpp +++ b/include/simgrid/s4u/Mailbox.hpp @@ -23,11 +23,6 @@ class XBT_PUBLIC Mailbox { explicit Mailbox(kernel::activity::MailboxImpl * mbox) : pimpl_(mbox) {} - /** private function to manage the mailboxes' lifetime (see @ref s4u_raii) */ - friend void intrusive_ptr_add_ref(Mailbox*) {} - /** private function to manage the mailboxes' lifetime (see @ref s4u_raii) */ - friend void intrusive_ptr_release(Mailbox*) {} - public: /** private function, do not use. FIXME: make me protected */ kernel::activity::MailboxImpl* get_impl() { return pimpl_; } @@ -38,7 +33,7 @@ public: const char* get_cname() const; /** Retrieve the mailbox associated to the given name */ - static MailboxPtr by_name(const std::string& name); + static Mailbox* by_name(const std::string& name); /** Returns whether the mailbox contains queued communications */ bool empty(); @@ -120,12 +115,12 @@ public: return get_impl(); } /** @deprecated Mailbox::by_name() */ - XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::by_name()") static MailboxPtr byName(const char* name) + XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::by_name()") static Mailbox* byName(const char* name) { return by_name(name); } /** @deprecated Mailbox::by_name() */ - XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::by_name()") static MailboxPtr byName(const std::string& name) + XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::by_name()") static Mailbox* byName(const std::string& name) { return by_name(name); } diff --git a/src/kernel/activity/MailboxImpl.hpp b/src/kernel/activity/MailboxImpl.hpp index 97b7576fe2..0c8246bd5c 100644 --- a/src/kernel/activity/MailboxImpl.hpp +++ b/src/kernel/activity/MailboxImpl.hpp @@ -23,7 +23,7 @@ class MailboxImpl { static constexpr size_t MAX_MAILBOX_SIZE = 10000000; friend s4u::Mailbox; - friend s4u::MailboxPtr s4u::Mailbox::by_name(const std::string& name); + friend s4u::Mailbox* s4u::Mailbox::by_name(const std::string& name); friend mc::CommunicationDeterminismChecker; explicit MailboxImpl(const std::string& name) diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 89aecf6fd3..6dfbfe2530 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -681,8 +681,6 @@ msg_comm_t MSG_task_irecv(msg_task_t* task, const char* name) */ msg_comm_t MSG_task_irecv_bounded(msg_task_t* task, const char* name, double rate) { - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(name); - /* FIXME: these functions are not traceable */ /* Sanity check */ xbt_assert(task, "Null pointer for the task storage"); diff --git a/src/plugins/vm/VmLiveMigration.cpp b/src/plugins/vm/VmLiveMigration.cpp index 825284fcf3..a4897579a8 100644 --- a/src/plugins/vm/VmLiveMigration.cpp +++ b/src/plugins/vm/VmLiveMigration.cpp @@ -357,7 +357,7 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm) /* wait until the migration have finished or on error has occurred */ XBT_DEBUG("wait for reception of the final ACK (i.e. migration has been correctly performed"); - simgrid::s4u::MailboxPtr mbox_ctl = simgrid::s4u::Mailbox::by_name( + simgrid::s4u::Mailbox* mbox_ctl = simgrid::s4u::Mailbox::by_name( std::string("__mbox_mig_ctl:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")"); delete static_cast(mbox_ctl->get()); tx->join(); diff --git a/src/plugins/vm/VmLiveMigration.hpp b/src/plugins/vm/VmLiveMigration.hpp index daff0fb38a..fd84132184 100644 --- a/src/plugins/vm/VmLiveMigration.hpp +++ b/src/plugins/vm/VmLiveMigration.hpp @@ -28,9 +28,9 @@ public: class MigrationRx { /* The miration_rx process uses mbox_ctl to let the caller of do_migration() know the completion of the migration. */ - s4u::MailboxPtr mbox_ctl; + s4u::Mailbox* mbox_ctl; /* The migration_rx and migration_tx processes use mbox to transfer migration data. */ - s4u::MailboxPtr mbox; + s4u::Mailbox* mbox; s4u::VirtualMachine* vm_; s4u::Host* src_pm_ = nullptr; s4u::Host* dst_pm_ = nullptr; @@ -50,7 +50,7 @@ public: class MigrationTx { /* The migration_rx and migration_tx processes use mbox to transfer migration data. */ - s4u::MailboxPtr mbox; + s4u::Mailbox* mbox; s4u::VirtualMachine* vm_; s4u::Host* src_pm_ = nullptr; s4u::Host* dst_pm_ = nullptr; diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index 5ef382122e..7aa422a49b 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -222,7 +222,7 @@ bool Comm::test() return false; } -MailboxPtr Comm::get_mailbox() +Mailbox* Comm::get_mailbox() { return mailbox_; } diff --git a/src/s4u/s4u_Mailbox.cpp b/src/s4u/s4u_Mailbox.cpp index 604cb6a6b6..16614427fa 100644 --- a/src/s4u/s4u_Mailbox.cpp +++ b/src/s4u/s4u_Mailbox.cpp @@ -25,13 +25,13 @@ const char* Mailbox::get_cname() const return pimpl_->get_cname(); } -MailboxPtr Mailbox::by_name(const std::string& name) +Mailbox* Mailbox::by_name(const std::string& name) { kernel::activity::MailboxImpl* mbox = kernel::activity::MailboxImpl::by_name_or_null(name); if (mbox == nullptr) { mbox = simix::simcall([&name] { return kernel::activity::MailboxImpl::by_name_or_create(name); }); } - return MailboxPtr(&mbox->piface_, true); + return &mbox->piface_; } bool Mailbox::empty() diff --git a/src/smpi/include/smpi_actor.hpp b/src/smpi/include/smpi_actor.hpp index 1314d4b430..5a2e33378e 100644 --- a/src/smpi/include/smpi_actor.hpp +++ b/src/smpi/include/smpi_actor.hpp @@ -17,8 +17,8 @@ namespace smpi { class ActorExt { private: double simulated_ = 0 /* Used to time with simulated_start/elapsed */; - s4u::MailboxPtr mailbox_; - s4u::MailboxPtr mailbox_small_; + s4u::Mailbox* mailbox_; + s4u::Mailbox* mailbox_small_; s4u::MutexPtr mailboxes_mutex_; xbt_os_timer_t timer_; MPI_Comm comm_self_ = MPI_COMM_NULL; @@ -58,8 +58,8 @@ public: smpi_trace_call_location_t* call_location(); void set_privatized_region(smpi_privatization_region_t region); smpi_privatization_region_t privatized_region(); - s4u::MailboxPtr mailbox() { return mailbox_; } - s4u::MailboxPtr mailbox_small() { return mailbox_small_; } + s4u::Mailbox* mailbox() { return mailbox_; } + s4u::Mailbox* mailbox_small() { return mailbox_small_; } s4u::MutexPtr mailboxes_mutex(); #if HAVE_PAPI int papi_event_set(); diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 8826c7cdaf..b79810ef8b 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -360,7 +360,7 @@ void Request::sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,int d void Request::start() { - s4u::MailboxPtr mailbox; + s4u::Mailbox* mailbox; xbt_assert(action_ == nullptr, "Cannot (re-)start unfinished communication"); flags_ &= ~MPI_REQ_PREPARED; @@ -706,7 +706,7 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* ->wait(); } // behave like a receive, but don't do it - s4u::MailboxPtr mailbox; + s4u::Mailbox* mailbox; request->print_request("New iprobe"); // We have to test both mailboxes as we don't know if we will receive one one or another diff --git a/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp b/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp index bc625c957f..756efd7f53 100644 --- a/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp +++ b/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp @@ -49,7 +49,7 @@ static void sender(std::vector args) for (unsigned int test = 1; test <= args[0].size(); test++) { simgrid::s4u::this_actor::sleep_until(test * 5 - 5); std::string* mboxName = new std::string("Test #" + std::to_string(test)); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(*mboxName); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(*mboxName); switch (args[0][test - 1]) { case 'r': @@ -96,7 +96,7 @@ static void receiver(std::vector args) for (unsigned int test = 1; test <= args[0].size(); test++) { simgrid::s4u::this_actor::sleep_until(test * 5 - 5); std::string mboxName = "Test #" + std::to_string(test); - simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(mboxName); + simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName); void* received = nullptr; switch (args[0][test - 1]) { diff --git a/teshsuite/s4u/listen_async/listen_async.cpp b/teshsuite/s4u/listen_async/listen_async.cpp index c1c5e0a4b7..20172e5548 100644 --- a/teshsuite/s4u/listen_async/listen_async.cpp +++ b/teshsuite/s4u/listen_async/listen_async.cpp @@ -15,7 +15,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example") static void server() { - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name("mailbox"); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("mailbox"); simgrid::s4u::CommPtr sendComm = mailbox->put_async(new std::string("Some data"), 0); @@ -28,7 +28,7 @@ static void server() delete res; sendComm->wait(); - simgrid::s4u::MailboxPtr mailbox2 = simgrid::s4u::Mailbox::by_name("mailbox2"); + simgrid::s4u::Mailbox* mailbox2 = simgrid::s4u::Mailbox::by_name("mailbox2"); mailbox2->set_receiver(simgrid::s4u::Actor::self()); mailbox2->put_init(new std::string("More data"), 0)->detach(); diff --git a/teshsuite/s4u/pid/pid.cpp b/teshsuite/s4u/pid/pid.cpp index 7fd0ac61a9..9f1099d9eb 100644 --- a/teshsuite/s4u/pid/pid.cpp +++ b/teshsuite/s4u/pid/pid.cpp @@ -9,7 +9,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this msg example") static void sendpid() { - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name("mailbox"); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("mailbox"); int pid = simgrid::s4u::this_actor::get_pid(); double comm_size = 100000; simgrid::s4u::this_actor::on_exit([pid](bool /*failed*/) { XBT_INFO("Process \"%d\" killed.", pid); }); @@ -23,7 +23,7 @@ static void sendpid() static void killall() { - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name("mailbox"); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("mailbox"); for (int i = 0; i < 3; i++) { int* pid = static_cast(mailbox->get()); XBT_INFO("Killing process \"%d\".", *pid); diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index b3bc3024be..7e2e9850e2 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -52,7 +52,7 @@ static void hsm_put(const std::string& remote_host, const std::string& src, cons // Send file XBT_INFO("%s sends %llu to %s", simgrid::s4u::this_actor::get_cname(), read_size, remote_host.c_str()); std::string* payload = new std::string(simgrid::xbt::string_printf("%s %llu", dest.c_str(), read_size)); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(remote_host); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(remote_host); mailbox->put(payload, static_cast(read_size)); simgrid::s4u::this_actor::sleep_for(.4); } @@ -122,7 +122,7 @@ static void client() hsm_put("alice", "/home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml", "c:\\Windows\\titi.xml"); hsm_put("alice", "/home/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c", "c:\\Windows\\tata.c"); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name("alice"); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("alice"); mailbox->put(new std::string("finalize"), 0); get_set_storage_data("Disk1"); @@ -131,7 +131,7 @@ static void client() static void server() { storage_info(simgrid::s4u::this_actor::get_host()); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_host()->get_cname()); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_host()->get_cname()); XBT_INFO("Server waiting for transfers ..."); while (1) {