wrench::S4U_Daemon
-
class wrench::S4U_Daemon
A generic “running daemon” abstraction that serves as a basis for all simulated processes.
Subclassed by wrench::Service
Public Types
Public Functions
-
S4U_Daemon(std::string hostname, std::string process_name_prefix)
Constructor (daemon with a mailbox)
- Parameters
hostname – the name of the host on which the daemon will run
process_name_prefix – the prefix of the name of the simulated process/actor
-
void acquireDaemonLock()
Method to acquire the daemon’s lock.
Lock the daemon’s lock.
-
virtual void cleanup(bool has_returned_from_main, int return_value)
Cleanup function called when the daemon terminates (for whatever reason). The default behavior is to throw an exception if the host is off. This method should be overriden in a daemons implements some fault-tolerant behavior, or is naturally tolerant.
- Parameters
has_returned_from_main – whether the daemon returned from main() by itself
return_value – the return value from main (if has_terminated_cleanly is true)
- Throws
std::runtime_error –
Create a life saver for the daemon.
- Parameters
reference –
-
std::string getName()
Retrieve the process name.
- Returns
the name
-
int getReturnValue()
Returns the value returned by main() (if the daemon has returned from main)
- Returns
The return value
-
Simulation *getSimulation()
Get the service’s simulation.
- Returns
a simulation
-
S4U_Daemon::State getState()
Get the daemon’s state.
- Returns
a state
-
bool hasReturnedFromMain()
Returns true if the daemon has returned from main() (i.e., not brutally killed)
- Returns
The true or false
-
bool isDaemonized()
Return the daemonized status of the daemon.
- Returns
true or false
-
bool isSetToAutoRestart()
Return the auto-restart status of the daemon.
- Returns
true or false
-
std::pair<bool, int> join()
Join (i.e., wait for) the daemon.
-
virtual int main() = 0
The daemon’s main method, to be overridden.
- Returns
0 on success, non-0 on failure!
-
void releaseDaemonLock()
Method to release the daemon’s lock.
Unlock the daemon’s lock.
-
void resumeActor()
Resume the daemon/actor.
-
void setSimulation(Simulation *simulation)
Set the service’s simulation.
- Parameters
simulation – a simulation
-
void setupOnExitFunction()
Sets up the on_exit function for the actor.
-
void startDaemon(bool _daemonized, bool _auto_restart)
Start the daemon.
- Parameters
daemonized – whether the S4U actor should be daemonized
auto_restart – whether the S4U actor should automatically restart after a host reboot
- Throws
std::runtime_error –
std::shared_ptr<HostError> –
-
void suspendActor()
Suspend the daemon/actor.
Public Members
-
std::string hostname
The name of the host on which the daemon is running.
-
simgrid::s4u::Mailbox *mailbox
The daemon’s mailbox.
-
std::string process_name
The name of the daemon.
-
simgrid::s4u::Mailbox *recv_mailbox
The daemon’s receive mailbox (to send to another daemon so that that daemon can reply)
Public Static Functions
-
static simgrid::s4u::Mailbox *getRunningActorRecvMailbox()
Return the running actor’s recv mailbox.
- Returns
the mailbox
Public Static Attributes
-
static std::unordered_map<aid_t, simgrid::s4u::Mailbox*> map_actor_to_recv_mailbox
A convenient map between actors and their default receive mailboxes.
-
S4U_Daemon(std::string hostname, std::string process_name_prefix)