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);
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)
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 *****
{
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() {
/** @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();
}
}
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)
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
~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
};
}