Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
comestics in src/kernel
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 13 Mar 2019 12:15:12 +0000 (13:15 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 13 Mar 2019 12:15:12 +0000 (13:15 +0100)
31 files changed:
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/CommImpl.hpp
src/kernel/activity/ConditionVariableImpl.cpp
src/kernel/activity/ConditionVariableImpl.hpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/kernel/activity/IoImpl.hpp
src/kernel/activity/MailboxImpl.cpp
src/kernel/activity/MailboxImpl.hpp
src/kernel/activity/MutexImpl.cpp
src/kernel/activity/MutexImpl.hpp
src/kernel/activity/SemaphoreImpl.cpp
src/kernel/activity/SemaphoreImpl.hpp
src/kernel/activity/SleepImpl.hpp
src/kernel/activity/SynchroRaw.cpp
src/kernel/activity/SynchroRaw.hpp
src/kernel/actor/ActorImpl.cpp
src/kernel/context/Context.cpp
src/kernel/context/Context.hpp
src/kernel/context/ContextBoost.cpp
src/kernel/context/ContextBoost.hpp
src/kernel/context/ContextRaw.cpp
src/kernel/context/ContextRaw.hpp
src/kernel/context/ContextThread.cpp
src/kernel/context/ContextThread.hpp
src/kernel/context/ContextUnix.cpp
src/kernel/context/ContextUnix.hpp
src/mc/mc_base.cpp
src/mc/mc_request.cpp

index ad9b5e1..77390cb 100644 (file)
 namespace simgrid {
 namespace kernel {
 
-EngineImpl::EngineImpl() = default;
 EngineImpl::~EngineImpl()
 {
   /* copy all names to not modify the map while iterating over it.
    *
-   * Plus, the hosts are destroyed in the lexicographic order to ensure
-   * that the output is reproducible: we don't want to kill them in the
-   * pointer order as it could be platform-dependent, which would break
-   * the tests.
+   * Plus, the hosts are destroyed in the lexicographic order to ensure that the output is reproducible: we don't want
+   * to kill them in the pointer order as it could be platform-dependent, which would break the tests.
    */
   std::vector<std::string> names;
   for (auto const& kv : hosts_)
index 27530d9..0778432 100644 (file)
@@ -13,19 +13,20 @@ namespace simgrid {
 namespace kernel {
 
 class EngineImpl {
+  std::map<std::string, s4u::Host*> hosts_;
+  std::map<std::string, s4u::Link*> links_;
+  std::map<std::string, s4u::Storage*> storages_;
+  std::unordered_map<std::string, routing::NetPoint*> netpoints_;
+  friend s4u::Engine;
+
 public:
-  EngineImpl();
+  EngineImpl() = default;
+  ;
   EngineImpl(const EngineImpl&) = delete;
   EngineImpl& operator=(const EngineImpl&) = delete;
   virtual ~EngineImpl();
-  kernel::routing::NetZoneImpl* netzone_root_ = nullptr;
-
-private:
-  std::map<std::string, simgrid::s4u::Host*> hosts_;
-  std::map<std::string, simgrid::s4u::Link*> links_;
-  std::map<std::string, simgrid::s4u::Storage*> storages_;
-  std::unordered_map<std::string, simgrid::kernel::routing::NetPoint*> netpoints_;
-  friend simgrid::s4u::Engine;
+  routing::NetZoneImpl* netzone_root_ = nullptr;
 };
-}
-}
+
+} // namespace kernel
+} // namespace simgrid
index 0bfa602..ed5dc6c 100644 (file)
@@ -47,9 +47,11 @@ private:
   std::string name_;                    /* Activity name if any */
 
 public:
-  static simgrid::xbt::signal<void(ActivityImplPtr)> on_suspended;
-  static simgrid::xbt::signal<void(ActivityImplPtr)> on_resumed;
+  static xbt::signal<void(ActivityImplPtr)> on_suspended;
+  static xbt::signal<void(ActivityImplPtr)> on_resumed;
 };
-}}} // namespace simgrid::kernel::activity
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
 
 #endif /* SIMGRID_KERNEL_ACTIVITY_ACTIVITYIMPL_HPP */
index 22710cf..f881e04 100644 (file)
@@ -32,22 +32,21 @@ public:
   void cancel();
   double remains();
 
-  CommImpl::Type type;          /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
-  smx_mailbox_t mbox = nullptr; /* Rendez-vous where the comm is queued */
+  CommImpl::Type type;         /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
+  MailboxImpl* mbox = nullptr; /* Rendez-vous where the comm is queued */
 
 #if SIMGRID_HAVE_MC
-  smx_mailbox_t mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
+  MailboxImpl* mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
                                      (comm.mbox set to nullptr when the communication is removed from the mailbox
                                      (used as garbage collector)) */
 #endif
   bool detached = false; /* If detached or not */
 
   void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */
-  int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*) =
-      nullptr; /* Filter function used by the other side. It is used when
+  int (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when
 looking if a given communication matches my needs. For that, myself must match the
 expectations of the other side, too. See  */
-  void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t) = nullptr;
+  void (*copy_data_fun)(CommImpl*, void*, size_t) = nullptr;
 
   /* Surf action data */
   resource::Action* surf_action_ = nullptr; /* The Surf communication action encapsulated */
@@ -68,8 +67,8 @@ expectations of the other side, too. See  */
   void* src_data_ = nullptr; /* User data associated to the communication */
   void* dst_data_ = nullptr;
 };
-}
-}
-} // namespace simgrid::kernel::activity
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
 
 #endif
index f57aa35..a46a904 100644 (file)
@@ -60,7 +60,7 @@ void ConditionVariableImpl::signal()
 
     /* Now transform the cond wait simcall into a mutex lock one */
     smx_simcall_t simcall = &proc.simcall;
-    smx_mutex_t simcall_mutex;
+    MutexImpl* simcall_mutex;
     if (simcall->call == SIMCALL_COND_WAIT)
       simcall_mutex = simcall_cond_wait__get__mutex(simcall);
     else
@@ -87,7 +87,7 @@ void ConditionVariableImpl::broadcast()
     signal();
 }
 
-void ConditionVariableImpl::wait(smx_mutex_t mutex, double timeout, smx_actor_t issuer, smx_simcall_t simcall)
+void ConditionVariableImpl::wait(smx_mutex_t mutex, double timeout, actor::ActorImpl* issuer, smx_simcall_t simcall)
 {
   XBT_IN("(%p, %p, %f, %p,%p)", this, mutex, timeout, issuer, simcall);
   RawImplPtr synchro = nullptr;
index 6749e78..f165dde 100644 (file)
@@ -19,13 +19,13 @@ public:
   ConditionVariableImpl();
   ~ConditionVariableImpl();
 
-  simgrid::kernel::actor::SynchroList sleeping_; /* list of sleeping processes */
-  smx_mutex_t mutex_ = nullptr;
-  simgrid::s4u::ConditionVariable cond_;
+  actor::SynchroList sleeping_; /* list of sleeping processes */
+  MutexImpl* mutex_ = nullptr;
+  s4u::ConditionVariable cond_;
 
   void broadcast();
   void signal();
-  void wait(smx_mutex_t mutex, double timeout, smx_actor_t issuer, smx_simcall_t simcall);
+  void wait(MutexImpl* mutex, double timeout, actor::ActorImpl* issuer, smx_simcall_t simcall);
 
 private:
   std::atomic_int_fast32_t refcount_{1};
index 452d6fd..4b66dd2 100644 (file)
@@ -224,7 +224,7 @@ void ExecImpl::finish()
   }
 }
 
-ActivityImpl* ExecImpl::migrate(simgrid::s4u::Host* to)
+ActivityImpl* ExecImpl::migrate(s4u::Host* to)
 {
   if (not MC_is_active() && not MC_record_replay_is_active()) {
     resource::Action* old_action = this->surf_action_;
index 607e671..74daa44 100644 (file)
@@ -15,6 +15,7 @@ namespace kernel {
 namespace activity {
 
 class XBT_PUBLIC ExecImpl : public ActivityImpl {
+  resource::Action* timeout_detector_ = nullptr;
   ~ExecImpl() override;
 
 public:
@@ -38,15 +39,11 @@ public:
   /* The host where the execution takes place. nullptr means this is a parallel exec (and only surf knows the hosts) */
   s4u::Host* host_ = nullptr;
 
-private:
-  resource::Action* timeout_detector_ = nullptr;
-
-public:
-  static simgrid::xbt::signal<void(ExecImplPtr)> on_creation;
-  static simgrid::xbt::signal<void(ExecImplPtr)> on_completion;
-  static simgrid::xbt::signal<void(ExecImplPtr, simgrid::s4u::Host*)> on_migration;
+  static xbt::signal<void(ExecImplPtr)> on_creation;
+  static xbt::signal<void(ExecImplPtr)> on_completion;
+  static xbt::signal<void(ExecImplPtr, s4u::Host*)> on_migration;
 };
-}
-}
-} // namespace simgrid::kernel::activity
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
 #endif
index 653d191..52d0aa7 100644 (file)
@@ -31,8 +31,8 @@ public:
   static xbt::signal<void(IoImplPtr)> on_start;
   static xbt::signal<void(IoImplPtr)> on_completion;
 };
-}
-}
-} // namespace simgrid::kernel::activity
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
 
 #endif
index ad182f2..9ead4ec 100644 (file)
@@ -40,7 +40,7 @@ MailboxImpl* MailboxImpl::by_name_or_create(const std::string& name)
   /* two processes may have pushed the same mbox_create simcall at the same time */
   auto m = mailboxes->find(name);
   if (m == mailboxes->end()) {
-    smx_mailbox_t mbox = new MailboxImpl(name);
+    MailboxImpl* mbox = new MailboxImpl(name);
     XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name.c_str());
     (*mailboxes)[mbox->name_] = mbox;
     return mbox;
@@ -151,6 +151,6 @@ CommImplPtr MailboxImpl::find_matching_comm(CommImpl::Type type, int (*match_fun
   XBT_DEBUG("No matching communication synchro found");
   return nullptr;
 }
-}
-}
-}
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
index 0c8246b..29b561c 100644 (file)
@@ -17,7 +17,7 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-/** @brief Implementation of the simgrid::s4u::Mailbox */
+/** @brief Implementation of the s4u::Mailbox */
 
 class MailboxImpl {
   static constexpr size_t MAX_MAILBOX_SIZE = 10000000;
@@ -32,7 +32,7 @@ class MailboxImpl {
   }
 
 public:
-  const simgrid::xbt::string& get_name() const { return name_; }
+  const xbt::string& get_name() const { return name_; }
   const char* get_cname() const { return name_.c_str(); }
   static MailboxImpl* by_name_or_null(const std::string& name);
   static MailboxImpl* by_name_or_create(const std::string& name);
@@ -44,18 +44,18 @@ public:
                                  const CommImplPtr& my_synchro, bool done, bool remove_matching);
 
 private:
-  simgrid::s4u::Mailbox piface_;
-  simgrid::xbt::string name_;
+  s4u::Mailbox piface_;
+  xbt::string name_;
 
 public:
-  simgrid::kernel::actor::ActorImplPtr permanent_receiver_; // actor to which the mailbox is attached
+  actor::ActorImplPtr permanent_receiver_; // actor to which the mailbox is attached
   boost::circular_buffer_space_optimized<CommImplPtr> comm_queue_;
   boost::circular_buffer_space_optimized<CommImplPtr> done_comm_queue_; // messages already received in the permanent
                                                                         // receive mode
 };
-}
-}
-}
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
 
 XBT_PRIVATE void SIMIX_mailbox_exit();
 
index 624c80b..883f135 100644 (file)
@@ -24,23 +24,23 @@ MutexImpl::~MutexImpl()
   XBT_OUT();
 }
 
-void MutexImpl::lock(smx_actor_t issuer)
+void MutexImpl::lock(actor::ActorImpl* issuer)
 {
   XBT_IN("(%p; %p)", this, issuer);
   /* FIXME: check where to validate the arguments */
   RawImplPtr synchro = nullptr;
 
-  if (this->locked) {
+  if (locked_) {
     /* FIXME: check if the host is active ? */
     /* Somebody using the mutex, use a synchronization to get host failures */
     synchro = RawImplPtr(new RawImpl())->start(issuer->get_host(), -1);
     synchro->simcalls_.push_back(&issuer->simcall);
     issuer->waiting_synchro = synchro;
-    this->sleeping.push_back(*issuer);
+    sleeping_.push_back(*issuer);
   } else {
     /* mutex free */
-    this->locked = true;
-    this->owner  = issuer;
+    locked_ = true;
+    owner_  = issuer;
     SIMIX_simcall_answer(&issuer->simcall);
   }
   XBT_OUT();
@@ -51,16 +51,16 @@ void MutexImpl::lock(smx_actor_t issuer)
  * @param  issuer  the process that tries to acquire the mutex
  * @return whether we managed to lock the mutex
  */
-bool MutexImpl::try_lock(smx_actor_t issuer)
+bool MutexImpl::try_lock(actor::ActorImpl* issuer)
 {
   XBT_IN("(%p, %p)", this, issuer);
-  if (this->locked) {
+  if (locked_) {
     XBT_OUT();
     return false;
   }
 
-  this->locked = true;
-  this->owner  = issuer;
+  locked_ = true;
+  owner_  = issuer;
   XBT_OUT();
   return true;
 }
@@ -71,28 +71,28 @@ bool MutexImpl::try_lock(smx_actor_t issuer)
  * If the unlocker is not the owner of the mutex nothing happens.
  * If there are no process waiting, it sets the mutex as free.
  */
-void MutexImpl::unlock(smx_actor_t issuer)
+void MutexImpl::unlock(actor::ActorImpl* issuer)
 {
   XBT_IN("(%p, %p)", this, issuer);
-  if (not this->locked)
+  if (not locked_)
     THROWF(mismatch_error, 0, "Cannot release that mutex: it was not locked.");
 
   /* If the mutex is not owned by the issuer, that's not good */
-  if (issuer != this->owner)
+  if (issuer != owner_)
     THROWF(mismatch_error, 0, "Cannot release that mutex: it was locked by %s (pid:%ld), not by you.",
-           this->owner->get_cname(), this->owner->get_pid());
+           owner_->get_cname(), owner_->get_pid());
 
-  if (not this->sleeping.empty()) {
+  if (not sleeping_.empty()) {
     /*process to wake up */
-    smx_actor_t p = &this->sleeping.front();
-    this->sleeping.pop_front();
+    actor::ActorImpl* p = &sleeping_.front();
+    sleeping_.pop_front();
     p->waiting_synchro = nullptr;
-    this->owner        = p;
+    owner_             = p;
     SIMIX_simcall_answer(&p->simcall);
   } else {
     /* nobody to wake up */
-    this->locked = false;
-    this->owner  = nullptr;
+    locked_ = false;
+    owner_  = nullptr;
   }
   XBT_OUT();
 }
index 37846cb..b60f735 100644 (file)
@@ -21,16 +21,16 @@ public:
   MutexImpl(MutexImpl const&) = delete;
   MutexImpl& operator=(MutexImpl const&) = delete;
 
-  void lock(smx_actor_t issuer);
-  bool try_lock(smx_actor_t issuer);
-  void unlock(smx_actor_t issuer);
+  void lock(actor::ActorImpl* issuer);
+  bool try_lock(actor::ActorImpl* issuer);
+  void unlock(actor::ActorImpl* issuer);
 
   MutexImpl* ref();
   void unref();
-  bool locked       = false;
-  smx_actor_t owner = nullptr;
-  // List of sleeping processes:
-  simgrid::kernel::actor::SynchroList sleeping;
+  bool locked_             = false;
+  actor::ActorImpl* owner_ = nullptr;
+  // List of sleeping actors:
+  actor::SynchroList sleeping_;
 
   // boost::intrusive_ptr<Mutex> support:
   friend void intrusive_ptr_add_ref(MutexImpl* mutex)
@@ -38,17 +38,18 @@ public:
     XBT_ATTRIB_UNUSED auto previous = mutex->refcount_.fetch_add(1);
     xbt_assert(previous != 0);
   }
+
   friend void intrusive_ptr_release(MutexImpl* mutex)
   {
     if (mutex->refcount_.fetch_sub(1) == 1)
       delete mutex;
   }
 
-  simgrid::s4u::Mutex& mutex() { return piface_; }
+  s4u::Mutex& mutex() { return piface_; }
 
 private:
   std::atomic_int_fast32_t refcount_{1};
-  simgrid::s4u::Mutex piface_;
+  s4u::Mutex piface_;
 };
 }
 }
index 86d1e9e..bf20f2b 100644 (file)
@@ -12,7 +12,7 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-void SemaphoreImpl::acquire(smx_actor_t issuer, double timeout)
+void SemaphoreImpl::acquire(actor::ActorImpl* issuer, double timeout)
 {
   RawImplPtr synchro = nullptr;
 
index b528e0e..73faa7b 100644 (file)
@@ -24,7 +24,7 @@ public:
   SemaphoreImpl(SemaphoreImpl const&) = delete;
   SemaphoreImpl& operator=(SemaphoreImpl const&) = delete;
 
-  void acquire(smx_actor_t issuer, double timeout);
+  void acquire(actor::ActorImpl* issuer, double timeout);
   void release();
   bool would_block() { return (value_ == 0); }
   unsigned int get_capacity() { return value_; }
index 32e6820..2bf4657 100644 (file)
@@ -24,8 +24,8 @@ public:
 
   sg_host_t host_ = nullptr;
 };
-}
-}
-} // namespace simgrid::kernel::activity
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
 
 #endif
index 8961561..d58e1e4 100644 (file)
@@ -80,7 +80,7 @@ void RawImpl::finish()
   switch (simcall->call) {
 
     case SIMCALL_MUTEX_LOCK:
-      simgrid::xbt::intrusive_erase(simcall_mutex_lock__get__mutex(simcall)->sleeping, *simcall->issuer);
+      simgrid::xbt::intrusive_erase(simcall_mutex_lock__get__mutex(simcall)->sleeping_, *simcall->issuer);
       break;
 
     case SIMCALL_COND_WAIT:
index 9115861..da5766b 100644 (file)
@@ -23,6 +23,8 @@ public:
   void post() override;
   void finish() override;
 };
-}}} // namespace simgrid::kernel::activity
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
 
 #endif
index 9e386fa..1c2fcfb 100644 (file)
@@ -145,7 +145,7 @@ void ActorImpl::cleanup()
     simgrid::xbt::intrusive_erase(host_->pimpl_->process_list_, *this);
   if (not smx_destroy_list_hook.is_linked()) {
 #if SIMGRID_HAVE_MC
-    xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, this);
+    xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this);
 #endif
     simix_global->actors_to_destroy.push_back(*this);
   }
@@ -367,15 +367,15 @@ void ActorImpl::resume()
   XBT_OUT();
 }
 
-activity::ActivityImplPtr ActorImpl::join(smx_actor_t actor, double timeout)
+activity::ActivityImplPtr ActorImpl::join(ActorImpl* actor, double timeout)
 {
   activity::ActivityImplPtr res = this->sleep(timeout);
   intrusive_ptr_add_ref(res.get());
   SIMIX_process_on_exit(actor,
                         [](int, void* arg) {
-                          auto sleep = static_cast<simgrid::kernel::activity::SleepImpl*>(arg);
+                          auto sleep = static_cast<activity::SleepImpl*>(arg);
                           if (sleep->surf_action_)
-                            sleep->surf_action_->finish(simgrid::kernel::resource::Action::State::FINISHED);
+                            sleep->surf_action_->finish(resource::Action::State::FINISHED);
                           intrusive_ptr_release(sleep);
                         },
                         res.get());
@@ -388,8 +388,7 @@ activity::ActivityImplPtr ActorImpl::sleep(double duration)
     throw_exception(std::make_exception_ptr(simgrid::HostFailureException(
         XBT_THROW_POINT, std::string("Host ") + host_->get_cname() + " failed, you cannot sleep there.")));
 
-  return simgrid::kernel::activity::SleepImplPtr(new simgrid::kernel::activity::SleepImpl("sleep", host_))
-      ->start(duration);
+  return activity::SleepImplPtr(new activity::SleepImpl("sleep", host_))->start(duration);
 }
 
 void ActorImpl::throw_exception(std::exception_ptr e)
@@ -438,14 +437,14 @@ void ActorImpl::throw_exception(std::exception_ptr e)
 
 void ActorImpl::set_host(s4u::Host* dest)
 {
-  simgrid::xbt::intrusive_erase(host_->pimpl_->process_list_, *this);
+  xbt::intrusive_erase(host_->pimpl_->process_list_, *this);
   host_ = dest;
   dest->pimpl_->process_list_.push_back(*this);
 }
 
 ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host)
 {
-  ActorImpl* actor = new ActorImpl(simgrid::xbt::string(name), host);
+  ActorImpl* actor = new ActorImpl(xbt::string(name), host);
   actor->set_ppid(this->pid_);
 
   intrusive_ptr_add_ref(actor);
@@ -490,9 +489,9 @@ ActorImplPtr ActorImpl::create(const std::string& name, const simix::ActorCode&
 
   ActorImplPtr actor;
   if (parent_actor != nullptr)
-    actor = parent_actor->init(simgrid::xbt::string(name), host);
+    actor = parent_actor->init(xbt::string(name), host);
   else
-    actor = SIMIX_process_self()->init(simgrid::xbt::string(name), host);
+    actor = SIMIX_process_self()->init(xbt::string(name), host);
 
   /* actor data */
   actor->set_user_data(data);
index 16517db..dc182b9 100644 (file)
@@ -41,19 +41,19 @@ void Context::declare_context(std::size_t size)
 #endif
 }
 
-Context* ContextFactory::attach(smx_actor_t)
+Context* ContextFactory::attach(actor::ActorImpl*)
 {
   xbt_die("Cannot attach with this ContextFactory.\n"
     "Try using --cfg=contexts/factory:thread instead.\n");
 }
 
-Context* ContextFactory::create_maestro(std::function<void()>&&, smx_actor_t)
+Context* ContextFactory::create_maestro(std::function<void()>&&, actor::ActorImpl*)
 {
   xbt_die("Cannot create_maestro with this ContextFactory.\n"
     "Try using --cfg=contexts/factory:thread instead.\n");
 }
 
-Context::Context(std::function<void()>&& code, smx_actor_t actor) : code_(std::move(code)), actor_(actor)
+Context::Context(std::function<void()>&& code, actor::ActorImpl* actor) : code_(std::move(code)), actor_(actor)
 {
   /* If no function was provided, this is the context for maestro
    * and we should set it as the current context */
@@ -112,7 +112,9 @@ void Context::stop()
 
 AttachContext::~AttachContext() = default;
 
-}}}
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
 
 /** @brief Executes all the processes to run (in parallel if possible). */
 void SIMIX_context_runall()
index ae50c28..60504fa 100644 (file)
@@ -22,12 +22,12 @@ public:
   ContextFactory(const ContextFactory&) = delete;
   ContextFactory& operator=(const ContextFactory&) = delete;
   virtual ~ContextFactory();
-  virtual Context* create_context(std::function<void()>&& code, smx_actor_t actor) = 0;
+  virtual Context* create_context(std::function<void()>&& code, actor::ActorImpl* actor) = 0;
 
   /** Turn the current thread into a simulation context */
-  virtual Context* attach(smx_actor_t actor);
+  virtual Context* attach(actor::ActorImpl* actor);
   /** Turn the current thread into maestro (the old maestro becomes a regular actor) */
-  virtual Context* create_maestro(std::function<void()>&& code, smx_actor_t actor);
+  virtual Context* create_maestro(std::function<void()>&& code, actor::ActorImpl* actor);
 
   virtual void run_all() = 0;
 
@@ -44,20 +44,20 @@ class XBT_PUBLIC Context {
   friend ContextFactory;
 
   std::function<void()> code_;
-  smx_actor_t actor_                  = nullptr;
+  actor::ActorImpl* actor_ = nullptr;
   void declare_context(std::size_t size);
 
 public:
   bool iwannadie = false;
 
-  Context(std::function<void()>&& code, smx_actor_t actor);
+  Context(std::function<void()>&& code, actor::ActorImpl* actor);
   Context(const Context&) = delete;
   Context& operator=(const Context&) = delete;
   virtual ~Context();
 
   void operator()() { code_(); }
   bool has_code() const { return static_cast<bool>(code_); }
-  smx_actor_t get_actor() { return this->actor_; }
+  actor::ActorImpl* get_actor() { return this->actor_; }
 
   // Scheduling methods
   virtual void stop();
@@ -72,7 +72,7 @@ public:
 
 class XBT_PUBLIC AttachContext : public Context {
 public:
-  AttachContext(std::function<void()>&& code, smx_actor_t actor) : Context(std::move(code), actor) {}
+  AttachContext(std::function<void()>&& code, actor::ActorImpl* actor) : Context(std::move(code), actor) {}
   AttachContext(const AttachContext&) = delete;
   AttachContext& operator=(const AttachContext&) = delete;
   ~AttachContext() override;
@@ -96,7 +96,9 @@ XBT_PRIVATE ContextFactory* sysv_factory();
 XBT_PRIVATE ContextFactory* raw_factory();
 XBT_PRIVATE ContextFactory* boost_factory();
 
-}}}
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
 
 typedef simgrid::kernel::context::ContextFactory *smx_context_factory_t;
 
index 9717474..1ba7c36 100644 (file)
@@ -15,14 +15,14 @@ namespace kernel {
 namespace context {
 
 // BoostContextFactory
-smx_context_t BoostContextFactory::create_context(std::function<void()>&& code, smx_actor_t actor)
+smx_context_t BoostContextFactory::create_context(std::function<void()>&& code, actor::ActorImpl* actor)
 {
   return this->new_context<BoostContext>(std::move(code), actor, this);
 }
 
 // BoostContext
 
-BoostContext::BoostContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory)
+BoostContext::BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory)
     : SwappedContext(std::move(code), actor, factory)
 {
 
@@ -103,4 +103,6 @@ XBT_PRIVATE ContextFactory* boost_factory()
   XBT_VERB("Using Boost contexts. Welcome to the 21th century.");
   return new BoostContextFactory();
 }
-}}} // namespace
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
index cac896c..082c6e8 100644 (file)
@@ -32,7 +32,7 @@ namespace context {
 /** @brief Userspace context switching implementation based on Boost.Context */
 class BoostContext : public SwappedContext {
 public:
-  BoostContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory);
+  BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
   ~BoostContext() override;
 
   void swap_into(SwappedContext* to) override;
@@ -54,8 +54,10 @@ private:
 
 class BoostContextFactory : public SwappedContextFactory {
 public:
-  Context* create_context(std::function<void()>&& code, smx_actor_t actor) override;
+  Context* create_context(std::function<void()>&& code, actor::ActorImpl* actor) override;
 };
-}}} // namespace
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
 
 #endif
index 328e8f5..11a7888 100644 (file)
@@ -188,14 +188,14 @@ namespace context {
 
 // RawContextFactory
 
-Context* RawContextFactory::create_context(std::function<void()>&& code, smx_actor_t actor)
+Context* RawContextFactory::create_context(std::function<void()>&& code, actor::ActorImpl* actor)
 {
   return this->new_context<RawContext>(std::move(code), actor, this);
 }
 
 // RawContext
 
-RawContext::RawContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory)
+RawContext::RawContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory)
     : SwappedContext(std::move(code), actor, factory)
 {
    if (has_code()) {
@@ -237,4 +237,6 @@ ContextFactory* raw_factory()
   XBT_VERB("Using raw contexts. Because the glibc is just not good enough for us.");
   return new RawContextFactory();
 }
-}}}
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
index 0749180..84c9055 100644 (file)
@@ -26,7 +26,7 @@ namespace context {
   */
 class RawContext : public SwappedContext {
 public:
-  RawContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory);
+  RawContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
 
   void swap_into(SwappedContext* to) override;
 
@@ -39,8 +39,10 @@ private:
 
 class RawContextFactory : public SwappedContextFactory {
 public:
-  Context* create_context(std::function<void()>&& code, smx_actor_t actor) override;
+  Context* create_context(std::function<void()>&& code, actor::ActorImpl* actor) override;
 };
-}}} // namespace
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
 
 #endif
index 3e2b066..d246a3c 100644 (file)
@@ -34,7 +34,7 @@ ThreadContextFactory::~ThreadContextFactory()
     ParallelThreadContext::finalize();
 }
 
-ThreadContext* ThreadContextFactory::create_context(std::function<void()>&& code, smx_actor_t actor, bool maestro)
+ThreadContext* ThreadContextFactory::create_context(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro)
 {
   if (parallel_)
     return this->new_context<ParallelThreadContext>(std::move(code), actor, maestro);
@@ -55,7 +55,7 @@ void ThreadContextFactory::run_all()
 
 // ThreadContext
 
-ThreadContext::ThreadContext(std::function<void()>&& code, smx_actor_t actor, bool maestro)
+ThreadContext::ThreadContext(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro)
     : AttachContext(std::move(code), actor), is_maestro_(maestro)
 {
   /* If the user provided a function for the actor then use it */
@@ -227,4 +227,6 @@ XBT_PRIVATE ContextFactory* thread_factory()
   XBT_VERB("Activating thread context factory");
   return new ThreadContextFactory();
 }
-}}} // namespace
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
index 63cf956..720e54b 100644 (file)
@@ -20,7 +20,7 @@ namespace context {
 
 class XBT_PUBLIC ThreadContext : public AttachContext {
 public:
-  ThreadContext(std::function<void()>&& code, smx_actor_t actor, bool maestro);
+  ThreadContext(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro);
   ThreadContext(const ThreadContext&) = delete;
   ThreadContext& operator=(const ThreadContext&) = delete;
   ~ThreadContext() override;
@@ -53,7 +53,7 @@ private:
 
 class XBT_PUBLIC SerialThreadContext : public ThreadContext {
 public:
-  SerialThreadContext(std::function<void()>&& code, smx_actor_t actor, bool maestro)
+  SerialThreadContext(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro)
       : ThreadContext(std::move(code), actor, maestro)
   {
   }
@@ -63,7 +63,7 @@ public:
 
 class ParallelThreadContext : public ThreadContext {
 public:
-  ParallelThreadContext(std::function<void()>&& code, smx_actor_t actor, bool maestro)
+  ParallelThreadContext(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro)
       : ThreadContext(std::move(code), actor, maestro)
   {
   }
@@ -85,7 +85,7 @@ public:
   ThreadContextFactory(const ThreadContextFactory&) = delete;
   ThreadContextFactory& operator=(const ThreadContextFactory&) = delete;
   ~ThreadContextFactory() override;
-  ThreadContext* create_context(std::function<void()>&& code, smx_actor_t actor) override
+  ThreadContext* create_context(std::function<void()>&& code, actor::ActorImpl* actor) override
   {
     bool maestro = not code;
     return create_context(std::move(code), actor, maestro);
@@ -93,8 +93,11 @@ public:
   void run_all() override;
 
   // Optional methods:
-  ThreadContext* attach(smx_actor_t actor) override { return create_context(std::function<void()>(), actor, false); }
-  ThreadContext* create_maestro(std::function<void()>&& code, smx_actor_t actor) override
+  ThreadContext* attach(actor::ActorImpl* actor) override
+  {
+    return create_context(std::function<void()>(), actor, false);
+  }
+  ThreadContext* create_maestro(std::function<void()>&& code, actor::ActorImpl* actor) override
   {
     return create_context(std::move(code), actor, true);
   }
@@ -102,8 +105,10 @@ public:
 private:
   bool parallel_;
 
-  ThreadContext* create_context(std::function<void()>&& code, smx_actor_t actor, bool maestro);
+  ThreadContext* create_context(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro);
 };
-}}} // namespace
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
 
 #endif
index 77b952e..9bae6d2 100644 (file)
@@ -56,7 +56,7 @@ namespace kernel {
 namespace context {
 
 // UContextFactory
-Context* UContextFactory::create_context(std::function<void()>&& code, smx_actor_t actor)
+Context* UContextFactory::create_context(std::function<void()>&& code, actor::ActorImpl* actor)
 {
   return new_context<UContext>(std::move(code), actor, this);
 }
@@ -64,7 +64,7 @@ Context* UContextFactory::create_context(std::function<void()>&& code, smx_actor
 
 // UContext
 
-UContext::UContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory)
+UContext::UContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory)
     : SwappedContext(std::move(code), actor, factory)
 {
   /* if the user provided a function for the actor then use it. If not, nothing to do for maestro. */
@@ -105,4 +105,6 @@ XBT_PRIVATE ContextFactory* sysv_factory()
   XBT_VERB("Activating SYSV context factory");
   return new UContextFactory();
 }
-}}} // namespace simgrid::kernel::context
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
index 96a1914..ac12cc8 100644 (file)
@@ -25,7 +25,7 @@ namespace context {
 
 class UContext : public SwappedContext {
 public:
-  UContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory);
+  UContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
 
   void swap_into(SwappedContext* to) override;
 
@@ -35,8 +35,10 @@ private:
 
 class UContextFactory : public SwappedContextFactory {
 public:
-  Context* create_context(std::function<void()>&& code, smx_actor_t actor) override;
+  Context* create_context(std::function<void()>&& code, actor::ActorImpl* actor) override;
 };
-}}} // namespace
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
 
 #endif
index 299dbde..a99957c 100644 (file)
@@ -117,9 +117,9 @@ bool actor_is_enabled(smx_actor_t actor)
     case SIMCALL_MUTEX_LOCK: {
       smx_mutex_t mutex = simcall_mutex_lock__get__mutex(req);
 
-      if (mutex->owner == nullptr)
+      if (mutex->owner_ == nullptr)
         return true;
-      return mutex->owner->get_pid() == req->issuer->get_pid();
+      return mutex->owner_->get_pid() == req->issuer->get_pid();
     }
 
     case SIMCALL_SEM_ACQUIRE: {
index 18c4014..c1bd140 100644 (file)
@@ -339,9 +339,9 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
         : simcall_mutex_trylock__get__mutex(req)
       ));
     args = bprintf(
-        "locked = %d, owner = %d, sleeping = n/a", mutex.getBuffer()->locked,
-        mutex.getBuffer()->owner != nullptr
-            ? (int)mc_model_checker->process().resolveActor(simgrid::mc::remote(mutex.getBuffer()->owner))->get_pid()
+        "locked = %d, owner = %d, sleeping = n/a", mutex.getBuffer()->locked_,
+        mutex.getBuffer()->owner_ != nullptr
+            ? (int)mc_model_checker->process().resolveActor(simgrid::mc::remote(mutex.getBuffer()->owner_))->get_pid()
             : -1);
     break;
   }