#ifndef SIMGRID_S4U_ACTOR_HPP
#define SIMGRID_S4U_ACTOR_HPP
+#include <stdexcept>
#include <xbt/base.h>
#include <simgrid/simix.h>
#include <simgrid/s4u/forward.hpp>
*
*/
XBT_PUBLIC_CLASS Actor {
- Actor(smx_process_t smx_proc);
+ explicit Actor(smx_process_t smx_proc);
public:
Actor(const char* name, s4u::Host *host, double killTime, std::function<void()> code);
Actor(const char* name, s4u::Host *host, std::function<void()> code)
*/
void kill();
+ static void kill(int pid);
+
// Static methods on all actors:
/** Ask kindly to all actors to die. Only the issuer will survive. */
static void killAll();
+protected:
+ smx_process_t getInferior() {return pimpl_;}
+private:
+ smx_process_t pimpl_ = nullptr;
+};
+
+namespace this_actor {
+
// Static methods working on the current actor:
/** Block the actor sleeping for that amount of seconds (may throws hostFailure) */
- static void sleep(double duration);
+ XBT_PUBLIC(void) sleep(double duration);
/** Block the actor, computing the given amount of flops */
- static e_smx_state_t execute(double flop);
+ XBT_PUBLIC(e_smx_state_t) execute(double flop);
/** Block the actor until it gets a message from the given mailbox.
*
* See \ref Comm for the full communication API (including non blocking communications).
*/
- static void *recv(Mailbox &chan);
+ XBT_PUBLIC(void*) recv(Mailbox &chan);
/** Block the actor until it delivers a message of the given simulated size to the given mailbox
*
* See \ref Comm for the full communication API (including non blocking communications).
*/
- static void send(Mailbox &chan, void*payload, size_t simulatedSize);
+ XBT_PUBLIC(void) send(Mailbox &chan, void*payload, size_t simulatedSize);
-protected:
- smx_process_t getInferior() {return pimpl_;}
-private:
- smx_process_t pimpl_ = nullptr;
};
}} // namespace simgrid::s4u