From 360d1e6510190d279551d9ca0510badccb1f8b37 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 10 Dec 2017 00:24:27 +0100 Subject: [PATCH] move exec_init and exec_async to the this_actor namespace --- examples/s4u/exec-async/s4u-exec-async.cpp | 2 +- .../s4u/exec-monitor/s4u-exec-monitor.cpp | 8 ++--- examples/s4u/exec-remote/s4u-exec-remote.cpp | 2 +- include/simgrid/s4u/Actor.hpp | 6 ++-- include/simgrid/s4u/Exec.hpp | 2 +- src/s4u/s4u_actor.cpp | 32 +++++++++---------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/s4u/exec-async/s4u-exec-async.cpp b/examples/s4u/exec-async/s4u-exec-async.cpp index 5813a4e166..1b75fc98f8 100644 --- a/examples/s4u/exec-async/s4u-exec-async.cpp +++ b/examples/s4u/exec-async/s4u-exec-async.cpp @@ -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(); diff --git a/examples/s4u/exec-monitor/s4u-exec-monitor.cpp b/examples/s4u/exec-monitor/s4u-exec-monitor.cpp index fb08720f88..88e51ce97c 100644 --- a/examples/s4u/exec-monitor/s4u-exec-monitor.cpp +++ b/examples/s4u/exec-monitor/s4u-exec-monitor.cpp @@ -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 diff --git a/examples/s4u/exec-remote/s4u-exec-remote.cpp b/examples/s4u/exec-remote/s4u-exec-remote.cpp index 6618bc92cd..de74a8c849 100644 --- a/examples/s4u/exec-remote/s4u-exec-remote.cpp +++ b/examples/s4u/exec-remote/s4u-exec-remote.cpp @@ -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 diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index b57d015e0c..8f332c81c7 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -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). diff --git a/include/simgrid/s4u/Exec.hpp b/include/simgrid/s4u/Exec.hpp index 8896f0e12e..b140bdbc61 100644 --- a/include/simgrid/s4u/Exec.hpp +++ b/include/simgrid/s4u/Exec.hpp @@ -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; diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index a437de0b6b..c888fb3a6f 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -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(); -- 2.20.1