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_)
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
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 */
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 */
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
/* 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
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;
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};
}
}
-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_;
namespace activity {
class XBT_PUBLIC ExecImpl : public ActivityImpl {
+ resource::Action* timeout_detector_ = nullptr;
~ExecImpl() override;
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
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
/* 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;
XBT_DEBUG("No matching communication synchro found");
return nullptr;
}
-}
-}
-}
+} // namespace activity
+} // namespace kernel
+} // 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;
}
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);
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();
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();
* @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;
}
* 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();
}
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)
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_;
};
}
}
namespace kernel {
namespace activity {
-void SemaphoreImpl::acquire(smx_actor_t issuer, double timeout)
+void SemaphoreImpl::acquire(actor::ActorImpl* issuer, double timeout)
{
RawImplPtr synchro = nullptr;
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_; }
sg_host_t host_ = nullptr;
};
-}
-}
-} // namespace simgrid::kernel::activity
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
#endif
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:
void post() override;
void finish() override;
};
-}}} // namespace simgrid::kernel::activity
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
#endif
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);
}
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());
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)
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);
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);
#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 */
AttachContext::~AttachContext() = default;
-}}}
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
/** @brief Executes all the processes to run (in parallel if possible). */
void SIMIX_context_runall()
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;
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();
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;
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;
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)
{
XBT_VERB("Using Boost contexts. Welcome to the 21th century.");
return new BoostContextFactory();
}
-}}} // namespace
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
/** @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;
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
// 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()) {
XBT_VERB("Using raw contexts. Because the glibc is just not good enough for us.");
return new RawContextFactory();
}
-}}}
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
*/
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;
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
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);
// 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 */
XBT_VERB("Activating thread context factory");
return new ThreadContextFactory();
}
-}}} // namespace
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
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;
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)
{
}
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)
{
}
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);
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);
}
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
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);
}
// 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. */
XBT_VERB("Activating SYSV context factory");
return new UContextFactory();
}
-}}} // namespace simgrid::kernel::context
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
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;
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
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: {
: 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;
}