From: Martin Quinson Date: Mon, 6 Mar 2017 23:56:42 +0000 (+0100) Subject: cosmetics in actors X-Git-Tag: v3_15~212^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ca9c9ec5eca4daafac1d841ff85a396e84952916 cosmetics in actors --- diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 56567c440f..d014ceff7d 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -155,12 +155,10 @@ XBT_PUBLIC_CLASS Actor : public simgrid::xbt::Extendable 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); diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 3f1c2b84ed..28833f1faf 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -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 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 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() { diff --git a/src/s4u/s4u_mailbox.cpp b/src/s4u/s4u_mailbox.cpp index 2fa5db2809..b2cbb4de69 100644 --- a/src/s4u/s4u_mailbox.cpp +++ b/src/s4u/s4u_mailbox.cpp @@ -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(); } } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 5553d28e98..403a5c29e2 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -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 code) diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index db307f1159..4464b6196b 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -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 }; }