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();
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
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
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
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).
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;
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 {
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();