foreach (example actions-comm actions-storage actor-create actor-daemon actor-kill actor-migration actor-suspend
- app-masterworker app-pingpong app-token-ring plugin-hostload io mutex async-waitany)
+ app-masterworker app-pingpong app-token-ring plugin-hostload io mutex async-waitany async-waitall)
add_executable (s4u_${example} ${example}/s4u_${example}.cpp)
target_link_libraries(s4u_${example} simgrid)
set_target_properties(s4u_${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u_app-bittorrent_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/s4u_app-masterworker_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u_async-waitany_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u_async-waitall_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u_dht-chord_d.xml PARENT_SCOPE)
set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u_actions-comm_split_p0.txt
${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u_actions-comm_split_p1.txt
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "simgrid/msg.h"
+ #include "simgrid/s4u.hpp"
+ #include "xbt/str.h"
+ #include <cstdlib>
+ #include <iostream>
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_waitall, "Messages specific for this msg example");
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 taskname[80];
snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
snprintf(taskname,79, "Task_%d", i);
- comms[i] = mbox->put_async((void*)mailbox, 42.0);
+ comms[i] = mbox->put_async((void*)taskname, 42);
XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i);
}
for (int i = 0; i < receivers_count; i++) {
char mailbox[80];
snprintf(mailbox,79, "receiver-%ld", i % receivers_count);
- comms[i + number_of_tasks] = mbox->put_async((void*)mailbox, 42.0);
+ comms[i + number_of_tasks] = mbox->put_async((void*)"finalize", 42);
XBT_INFO("Send to receiver-%ld finalize", i % receivers_count);
}
/* Here we are waiting for the completion of all communications */
for (int i = 0; i < number_of_tasks + receivers_count; i++)
- comms[i]->wai();
+ comms[i]->wait();
delete [] comms;
}
int id = xbt_str_parse_int(args[0].c_str(), "Any process of this example must have a numerical name, not %s");
void *received;
char mailbox[80];
+ simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName("receiver_mailbox");
snprintf(mailbox,79, "receiver-%d", id);
simgrid::s4u::this_actor::sleep_for(10.0);
while (1) {
XBT_INFO("Wait to receive a task");
received = NULL;
- comm = mbox->get_async(&received);
+ simgrid::s4u::CommPtr comm = mbox->get_async(&received);
comm->wait();
- if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
- MSG_task_destroy(task);
+ if (strcmp(received, "finalize") == 0) {
+ delete received;
break;
}
- XBT_INFO("Processing \"%s\"", MSG_task_get_name(task));
- MSG_task_execute(task);
- XBT_INFO("\"%s\" done", MSG_task_get_name(task));
- MSG_task_destroy(task);
+ XBT_INFO("Processing \"%s\"", received);
+ // MSG_task_execute(task);
+ XBT_INFO("\"%s\" done", recieved);
+ delete recieved;
}
XBT_INFO("I'm done. See you!");
}
int main(int argc, char *argv[])
{
- MSG_init(&argc, argv);
+ simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv);
+
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
"\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
- MSG_create_environment(argv[1]);
- MSG_function_register("sender", sender);
- MSG_function_register("receiver", receiver);
- MSG_launch_application(argv[2]);
-
- msg_error_t res = MSG_main();
+ e->registerFunction<sender>("sender");
+ e->registerFunction<receiver>("receiver");
- XBT_INFO("Simulation time %g", MSG_get_clock());
+ e->loadDeployment(argv[2]);
+ e->run();
- return res != MSG_OK;
+ return 0;
}