- void operator()() const
- {
- // sphinx-doc: init-begin (this line helps the doc to build; ignore it)
- /* Vector in which we store all ongoing communications */
- std::vector<sg4::CommPtr> pending_comms;
-
- /* Make a vector of the mailboxes to use */
- std::vector<sg4::Mailbox*> mboxes;
- for (int i = 0; i < receivers_count; i++)
- mboxes.push_back(sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(i)));
- // sphinx-doc: init-end
-
- /* Start dispatching all messages to receivers, in a round robin fashion */
- for (int i = 0; i < messages_count; i++) {
- std::string msg_content = std::string("Message ") + std::to_string(i);
- // Copy the data we send: the 'msg_content' variable is not a stable storage location.
- // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
- auto* payload = new std::string(msg_content);
-
- XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mboxes[i % receivers_count]->get_cname());
-
- /* Create a communication representing the ongoing communication, and store it in pending_comms */
- sg4::CommPtr comm = mboxes[i % receivers_count]->put_async(payload, msg_size);
- pending_comms.push_back(comm);
- }
-
- /* Start sending messages to let the workers know that they should stop */ // sphinx-doc: put-begin
- for (int i = 0; i < receivers_count; i++) {
- XBT_INFO("Send 'finalize' to 'receiver-%d'", i);
- sg4::CommPtr comm = mboxes[i]->put_async(new std::string("finalize"), 0);
- pending_comms.push_back(comm);
- }
- XBT_INFO("Done dispatching all messages");
-
- /* Now that all message exchanges were initiated, wait for their completion in one single call */
- sg4::Comm::wait_all(&pending_comms);
- // sphinx-doc: put-end
-
- XBT_INFO("Goodbye now!");
+ // sphinx-doc: init-begin (this line helps the doc to build; ignore it)
+ /* Vector in which we store all ongoing communications */
+ std::vector<sg4::CommPtr> pending_comms;
+
+ /* Make a vector of the mailboxes to use */
+ std::vector<sg4::Mailbox*> mboxes;
+ for (unsigned int i = 0; i < receivers_count; i++)
+ mboxes.push_back(sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(i)));
+ // sphinx-doc: init-end
+
+ /* Start dispatching all messages to receivers, in a round robin fashion */
+ for (unsigned int i = 0; i < messages_count; i++) {
+ std::string msg_content = std::string("Message ") + std::to_string(i);
+ // Copy the data we send: the 'msg_content' variable is not a stable storage location.
+ // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
+ auto* payload = new std::string(msg_content);
+
+ XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mboxes[i % receivers_count]->get_cname());
+
+ /* Create a communication representing the ongoing communication, and store it in pending_comms */
+ sg4::CommPtr comm = mboxes[i % receivers_count]->put_async(payload, msg_size);
+ pending_comms.push_back(comm);