- long number_of_tasks = xbt_str_parse_int(args[0].c_str(), "Invalid amount of tasks: %s");
- double task_comp_size = xbt_str_parse_double(args[1].c_str(), "Invalid computational size: %s");
- double task_comm_size = xbt_str_parse_double(args[2].c_str(), "Invalid communication size: %s");
- long receivers_count = xbt_str_parse_int(args[3].c_str(), "Invalid amount of receivers: %s");
-
- simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName("receiver_mailbox");
- simgrid::s4u::CommPtr* comms = new simgrid::s4u::CommPtr[number_of_tasks + receivers_count] ;
-
- for (int i = 0; i < number_of_tasks; i++) {
- char mailbox[80];
- char taskname[80];
- snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
- snprintf(taskname,79, "Task_%d", i);
- comms[i] = mbox->put_async((void*)taskname, 42);
- XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
+ messages_count = std::stol(args[1]);
+ msg_size = std::stod(args[2]);
+ receivers_count = std::stol(args[3]);
+
+}
+void operator()()
+{
+ simgrid::s4u::CommPtr* comms = new simgrid::s4u::CommPtr[messages_count + receivers_count];
+
+ /* Start dispatching all messages to receivers, in a round robin fashion */
+ 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::byName(mboxName);
+ std::string msgName = std::string("Message ") + std::to_string(i);
+ char* payload = xbt_strdup(msgName.c_str()); // copy the data we send: 'msgName' is not a stable storage location
+
+ XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
+ comms[i] = mbox->put_async((void*)payload, msg_size);