From 1590bc9ec710e9849ddfd70a02b0842ca0206dbf Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 13 Mar 2022 16:24:36 +0100 Subject: [PATCH] Sort Actor traits alphabetically + cleanups --- src/kernel/actor/ActorImpl.cpp | 2 +- src/kernel/actor/ActorImpl.hpp | 37 +++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 6ffc7de65b..17aa4afda3 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -38,6 +38,7 @@ namespace simgrid { namespace kernel { namespace actor { +/*------------------------- [ ActorIDTrait ] -------------------------*/ static unsigned long maxpid = 0; unsigned long get_maxpid() { @@ -47,7 +48,6 @@ unsigned long* get_maxpid_addr() { return &maxpid; } - ActorIDTrait::ActorIDTrait(std::string name, aid_t ppid) : name_(std::move(name)), pid_(maxpid++), ppid_(ppid) {} ActorImpl* ActorImpl::by_pid(aid_t pid) diff --git a/src/kernel/actor/ActorImpl.hpp b/src/kernel/actor/ActorImpl.hpp index a6a6507366..d6c3a36f1f 100644 --- a/src/kernel/actor/ActorImpl.hpp +++ b/src/kernel/actor/ActorImpl.hpp @@ -21,18 +21,7 @@ namespace kernel { namespace actor { class ProcessArg; -class XBT_PUBLIC ActorRestartingTrait { - bool auto_restart_ = false; - int restart_count_ = 0; - - friend ActorImpl; - -public: - bool has_to_auto_restart() const { return auto_restart_; } - void set_auto_restart(bool autorestart) { auto_restart_ = autorestart; } - int get_restart_count() const { return restart_count_; } -}; - +/*------------------------- [ ActorIDTrait ] -------------------------*/ class XBT_PUBLIC ActorIDTrait { xbt::string name_; aid_t pid_ = 0; @@ -48,7 +37,21 @@ public: XBT_PUBLIC unsigned long get_maxpid(); XBT_PUBLIC unsigned long* get_maxpid_addr(); // In MC mode, the application sends this pointers to the MC -class XBT_PUBLIC ActorImpl : public xbt::PropertyHolder, public ActorRestartingTrait, public ActorIDTrait { +/*------------------------- [ ActorRestartingTrait ] -------------------------*/ +class XBT_PUBLIC ActorRestartingTrait { + bool auto_restart_ = false; + int restart_count_ = 0; + + friend ActorImpl; + +public: + bool has_to_auto_restart() const { return auto_restart_; } + void set_auto_restart(bool autorestart) { auto_restart_ = autorestart; } + int get_restart_count() const { return restart_count_; } +}; + +/*------------------------- [ ActorImpl ] -------------------------*/ +class XBT_PUBLIC ActorImpl : public xbt::PropertyHolder, public ActorIDTrait, public ActorRestartingTrait { s4u::Host* host_ = nullptr; /* the host on which the actor is running */ bool daemon_ = false; /* Daemon actors are automatically killed when the last non-daemon leaves */ unsigned stacksize_; // set to default value in constructor @@ -84,12 +87,16 @@ public: // Accessors to private fields s4u::Host* get_host() const { return host_; } void set_host(s4u::Host* dest); - bool is_daemon() const { return daemon_; } /** Whether this actor has been daemonized */ bool is_maestro() const; /** Whether this actor is actually maestro (cheap call but may segfault before actor creation / after terminaison) */ void set_stacksize(unsigned stacksize) { stacksize_ = stacksize; } unsigned get_stacksize() const { return stacksize_; } + // Daemonize + bool is_daemon() const { return daemon_; } /** Whether this actor has been daemonized */ + void daemonize(); + void undaemonize(); + std::unique_ptr context_; /* the context (uctx/raw/thread) that executes the user function */ std::exception_ptr exception_; @@ -137,7 +144,6 @@ public: private: s4u::Actor piface_; // Our interface is part of ourselves - void undaemonize(); public: s4u::ActorPtr get_iface() { return s4u::ActorPtr(&piface_); } @@ -158,7 +164,6 @@ public: void kill_all() const; void yield(); - void daemonize(); bool is_suspended() const { return suspended_; } s4u::Actor* restart(); void suspend(); -- 2.20.1