Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move exec_init and exec_async to the this_actor namespace
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 9 Dec 2017 23:24:27 +0000 (00:24 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 9 Dec 2017 23:24:27 +0000 (00:24 +0100)
examples/s4u/exec-async/s4u-exec-async.cpp
examples/s4u/exec-monitor/s4u-exec-monitor.cpp
examples/s4u/exec-remote/s4u-exec-remote.cpp
include/simgrid/s4u/Actor.hpp
include/simgrid/s4u/Exec.hpp
src/s4u/s4u_actor.cpp

index 5813a4e..1b75fc9 100644 (file)
@@ -12,7 +12,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example")
 static void test(double computation_amount, double priority)
 {
   XBT_INFO("Hello! Execute %g flops with priority %g", computation_amount, priority);
-  simgrid::s4u::ExecPtr activity = simgrid::s4u::Actor::self()->exec_init(computation_amount);
+  simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
   activity->setPriority(priority);
   activity->start();
   activity->wait();
index fb08720..88e51ce 100644 (file)
@@ -22,16 +22,16 @@ static void monitor(simgrid::s4u::ExecPtr activity)
 static void executor()
 {
   XBT_INFO("Create one monitored task, and wait for it");
-  simgrid::s4u::ExecPtr activity = simgrid::s4u::Actor::self()->exec_async(1e9);
+  simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_async(1e9);
   simgrid::s4u::Actor::createActor("monitor 1", simgrid::s4u::Host::by_name("Tremblay"), monitor, activity);
   activity->wait(); // This blocks until the activity is over
   XBT_INFO("The monitored task is over. Let's start 3 of them now.");
   simgrid::s4u::Actor::createActor("monitor 2", simgrid::s4u::Host::by_name("Jupiter"), monitor,
-                                   simgrid::s4u::Actor::self()->exec_async(1e9));
+                                   simgrid::s4u::this_actor::exec_async(1e9));
   simgrid::s4u::Actor::createActor("monitor 3", simgrid::s4u::Host::by_name("Ginette"), monitor,
-                                   simgrid::s4u::Actor::self()->exec_async(1e9));
+                                   simgrid::s4u::this_actor::exec_async(1e9));
   simgrid::s4u::Actor::createActor("monitor 4", simgrid::s4u::Host::by_name("Bourassa"), monitor,
-                                   simgrid::s4u::Actor::self()->exec_async(1e9));
+                                   simgrid::s4u::this_actor::exec_async(1e9));
   XBT_INFO("All activities are started; finish now");
   // Waiting execution activities is not mandatory: they go to completion once started
 
index 6618bc9..de74a8c 100644 (file)
@@ -14,7 +14,7 @@ static void wizard()
   simgrid::s4u::Host* ginette = simgrid::s4u::Host::by_name("Ginette");
 
   XBT_INFO("I'm a wizard! I can run a task on the Fafard host from the Ginette one! Look!");
-  simgrid::s4u::ExecPtr activity = simgrid::s4u::Actor::self()->exec_init(48.492e6);
+  simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(48.492e6);
   activity->setHost(ginette);
   activity->start();
   // TODO: display the load of each hosts once it gets possible
index b57d015..8f332c8 100644 (file)
@@ -275,9 +275,6 @@ public:
   const char* getProperty(const char* key);
   void setProperty(const char* key, const char* value);
   Actor* restart();
-
-  ExecPtr exec_init(double flops_amounts);
-  ExecPtr exec_async(double flops_amounts);
 };
 
 /** @ingroup s4u_api
@@ -319,6 +316,9 @@ XBT_PUBLIC(void) parallel_execute(int host_nb, sg_host_t* host_list, double* flo
 XBT_PUBLIC(void)
 parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double timeout);
 
+XBT_PUBLIC(ExecPtr) exec_init(double flops_amounts);
+XBT_PUBLIC(ExecPtr) exec_async(double flops_amounts);
+
 /** Block the actor until it gets a message from the given mailbox.
  *
  * See \ref Comm for the full communication API (including non blocking communications).
index 8896f0e..b140bdb 100644 (file)
@@ -21,7 +21,7 @@ XBT_PUBLIC_CLASS Exec : public Activity
 public:
   friend void intrusive_ptr_release(simgrid::s4u::Exec * e);
   friend void intrusive_ptr_add_ref(simgrid::s4u::Exec * e);
-  friend Actor; // Factory of Exec
+  friend ExecPtr this_actor::exec_init(double flops_amount);
 
   ~Exec() = default;
 
index a437de0..c888fb3 100644 (file)
@@ -198,22 +198,6 @@ Actor* Actor::restart()
   return simgrid::simix::kernelImmediate([this]() { return pimpl_->restart(); });
 }
 
-ExecPtr Actor::exec_init(double flops_amount)
-{
-  ExecPtr res        = ExecPtr(new Exec());
-  res->host_         = this->getHost();
-  res->flops_amount_ = flops_amount;
-  res->setRemains(flops_amount);
-  return res;
-}
-
-ExecPtr Actor::exec_async(double flops)
-{
-  ExecPtr res = exec_init(flops);
-  res->start();
-  return res;
-}
-
 // ***** this_actor *****
 
 namespace this_actor {
@@ -276,6 +260,22 @@ void parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, d
   simcall_execution_wait(s);
 }
 
+ExecPtr exec_init(double flops_amount)
+{
+  ExecPtr res        = ExecPtr(new Exec());
+  res->host_         = getHost();
+  res->flops_amount_ = flops_amount;
+  res->setRemains(flops_amount);
+  return res;
+}
+
+ExecPtr exec_async(double flops)
+{
+  ExecPtr res = exec_init(flops);
+  res->start();
+  return res;
+}
+
 void* recv(MailboxPtr chan) // deprecated
 {
   return chan->get();