Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics in actors
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 6 Mar 2017 23:56:42 +0000 (00:56 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 7 Mar 2017 00:10:35 +0000 (01:10 +0100)
include/simgrid/s4u/Actor.hpp
src/s4u/s4u_actor.cpp
src/s4u/s4u_mailbox.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp

index 56567c4..d014cef 100644 (file)
@@ -155,12 +155,10 @@ XBT_PUBLIC_CLASS Actor : public simgrid::xbt::Extendable<Actor>
 public:
 
   // ***** No copy *****
-
   Actor(Actor const&) = delete;
   Actor& operator=(Actor const&) = delete;
 
   // ***** Reference count (delegated to pimpl_) *****
-
   friend void intrusive_ptr_add_ref(Actor* actor)
   {
     xbt_assert(actor != nullptr);
index 3f1c2b8..28833f1 100644 (file)
@@ -25,13 +25,13 @@ ActorPtr Actor::self()
   if (self_context == nullptr)
     return simgrid::s4u::ActorPtr();
 
-  return simgrid::s4u::ActorPtr(&self_context->process()->getIface());
+  return self_context->process()->iface();
 }
 
 ActorPtr Actor::createActor(const char* name, s4u::Host* host, std::function<void()> code)
 {
   smx_actor_t actor = simcall_process_create(name, std::move(code), nullptr, host, nullptr);
-  return ActorPtr(&actor->getIface());
+  return actor->iface();
 }
 
 ActorPtr Actor::createActor(const char* name, s4u::Host* host, const char* function, std::vector<std::string> args)
@@ -39,7 +39,7 @@ ActorPtr Actor::createActor(const char* name, s4u::Host* host, const char* funct
   simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
   simgrid::simix::ActorCode code = factory(std::move(args));
   smx_actor_t actor                         = simcall_process_create(name, std::move(code), nullptr, host, nullptr);
-  return ActorPtr(&actor->getIface());
+  return actor->iface();
 }
 
 // ***** Actor methods *****
@@ -106,9 +106,9 @@ ActorPtr Actor::byPid(int pid)
 {
   smx_actor_t process = SIMIX_process_from_PID(pid);
   if (process != nullptr)
-    return ActorPtr(&process->getIface());
+    return process->iface();
   else
-    return nullptr;
+    return ActorPtr();
 }
 
 void Actor::killAll() {
index 2fa5db2..b2cbb4d 100644 (file)
@@ -54,9 +54,9 @@ void Mailbox::setReceiver(ActorPtr actor) {
 
 /** @brief get the receiver (process associated to the mailbox) */
 ActorPtr Mailbox::receiver() {
-  if(pimpl_->permanent_receiver == nullptr)
+  if (pimpl_->permanent_receiver == nullptr)
     return ActorPtr();
-  return ActorPtr(&pimpl_->permanent_receiver->getIface());
+  return pimpl_->permanent_receiver->iface();
 }
 
 }
index 5553d28..403a5c2 100644 (file)
@@ -165,10 +165,8 @@ namespace simix {
 ActorImpl::~ActorImpl()
 {
   delete this->context;
-  if (this->properties)
-    xbt_dict_free(&this->properties);
-  if (this->on_exit)
-    xbt_dynar_free(&this->on_exit);
+  xbt_dict_free(&this->properties);
+  xbt_dynar_free(&this->on_exit);
 }
 
 void create_maestro(std::function<void()> code)
index db307f1..4464b61 100644 (file)
@@ -44,7 +44,7 @@ public:
   unsigned long ppid = -1;
   simgrid::xbt::string name;
   const char* cname() { return name.c_str(); }
-  sg_host_t host        = nullptr; /* the host on which the process is running */
+  s4u::Host* host       = nullptr; /* the host on which the process is running */
   smx_context_t context = nullptr; /* the context (uctx/raw/thread) that executes the user function */
 
   // TODO, pack them
@@ -83,11 +83,11 @@ public:
 
   ~ActorImpl();
 
-  simgrid::s4u::Actor& getIface() { return piface_; }
+  simgrid::s4u::ActorPtr iface() { return s4u::ActorPtr(&piface_); }
 
 private:
   std::atomic_int_fast32_t refcount_ { 1 };
-  simgrid::s4u::Actor piface_;
+  simgrid::s4u::Actor piface_; // Our interface is part of ourselves
 };
 
 }