Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / src / kernel / actor / ActorImpl.hpp
index 5ea6048..69741ac 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -9,33 +9,38 @@
 #include "Simcall.hpp"
 #include "simgrid/kernel/Timer.hpp"
 #include "simgrid/s4u/Actor.hpp"
+#include "src/kernel/actor/Simcall.hpp"
 #include "xbt/PropertyHolder.hpp"
+
+#include <atomic>
 #include <boost/intrusive/list.hpp>
 #include <functional>
 #include <list>
 #include <map>
+#include <set>
+#include <unordered_set>
 #include <memory>
 
-namespace simgrid {
-namespace kernel {
-namespace actor {
+namespace simgrid::kernel::actor {
 class ProcessArg;
 
 /*------------------------- [ ActorIDTrait ] -------------------------*/
 class XBT_PUBLIC ActorIDTrait {
-  xbt::string name_;
-  aid_t pid_         = 0;
-  aid_t ppid_        = -1;
+  std::string name_;
+  aid_t pid_  = 0;
+  aid_t ppid_ = -1;
+
+  static unsigned long maxpid_;
 
 public:
-  explicit ActorIDTrait(std::string name, aid_t ppid);
-  const xbt::string& get_name() const { return name_; }
+  explicit ActorIDTrait(const std::string& name, aid_t ppid);
+  const std::string& get_name() const { return name_; }
   const char* get_cname() const { return name_.c_str(); }
   aid_t get_pid() const { return pid_; }
   aid_t get_ppid() const { return ppid_; }
+
+  static unsigned long get_maxpid() { return maxpid_; }
 };
-XBT_PUBLIC unsigned long get_maxpid();
-XBT_PUBLIC unsigned long* get_maxpid_addr(); // In MC mode, the application sends this pointers to the MC
 
 /*------------------------- [ ActorRestartingTrait ] -------------------------*/
 class XBT_PUBLIC ActorRestartingTrait {
@@ -62,7 +67,7 @@ class XBT_PUBLIC ActorImpl : public xbt::PropertyHolder, public ActorIDTrait, pu
   friend activity::MailboxImpl;
 
 public:
-  ActorImpl(xbt::string name, s4u::Host* host, aid_t ppid);
+  ActorImpl(const std::string& name, s4u::Host* host, aid_t ppid);
   ActorImpl(const ActorImpl&) = delete;
   ActorImpl& operator=(const ActorImpl&) = delete;
   ~ActorImpl();
@@ -100,7 +105,7 @@ public:
   bool suspended_ = false;
 
   activity::ActivityImplPtr waiting_synchro_ = nullptr; /* the current blocking synchro if any */
-  std::list<activity::ActivityImplPtr> activities_;     /* the current non-blocking synchros */
+  std::set<activity::ActivityImplPtr> activities_;     /* the current non-blocking synchros */
   Simcall simcall_;
   /* list of functions executed when the actor dies */
   std::shared_ptr<std::vector<std::function<void(bool)>>> on_exit =
@@ -114,7 +119,7 @@ private:
   std::atomic_int_fast32_t refcount_{0};
 
 public:
-  int get_refcount() const { return refcount_; }
+  int get_refcount() const { return static_cast<int>(refcount_); }
   friend void intrusive_ptr_add_ref(ActorImpl* actor)
   {
     // This whole memory consistency semantic drives me nuts.
@@ -231,8 +236,6 @@ using SynchroList =
 
 XBT_PUBLIC void create_maestro(const std::function<void()>& code);
 
-} // namespace actor
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::actor
 
 #endif