Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Create actor by passing function and arguments
[simgrid.git] / examples / s4u / basic / s4u_basic.cpp
index 3da68af..12156f2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2015. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved.          */
 
 /* 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. */
@@ -13,7 +13,8 @@ class Worker {
 public:
   void operator()() {
     XBT_INFO("Hello s4u, I'm ready to serve");
-    char *msg = (char*)simgrid::s4u::Actor::recv(*simgrid::s4u::Mailbox::byName("worker"));
+    char *msg = static_cast<char*>(simgrid::s4u::this_actor::recv(
+      *simgrid::s4u::Mailbox::byName("worker")));
     XBT_INFO("I received '%s'",msg);
     XBT_INFO("I'm done. See you.");
   }
@@ -24,7 +25,7 @@ public:
   void operator()() {
     const char *msg = "GaBuZoMeu";
     XBT_INFO("Hello s4u, I have something to send");
-    simgrid::s4u::Actor::send(*simgrid::s4u::Mailbox::byName("worker"), xbt_strdup(msg), strlen(msg));
+    simgrid::s4u::this_actor::send(*simgrid::s4u::Mailbox::byName("worker"), xbt_strdup(msg), strlen(msg));
     XBT_INFO("I'm done. See you.");
   }
 };
@@ -32,9 +33,9 @@ public:
 
 int main(int argc, char **argv) {
   simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv);
-  e->loadPlatform("../../platforms/two_hosts_platform.xml");
-  new simgrid::s4u::Actor("worker", simgrid::s4u::Host::by_name("host0"), Worker());
-  new simgrid::s4u::Actor("master", simgrid::s4u::Host::by_name("host1"), 0, Master());
+  e->loadPlatform("../../platforms/two_hosts.xml");
+  simgrid::s4u::Actor("worker", simgrid::s4u::Host::by_name("Tremblay"), Worker());
+  simgrid::s4u::Actor("master", simgrid::s4u::Host::by_name("Jupiter"), Master());
   e->run();
   return 0;
 }