return static_cast<JavaContext*>(xbt_os_thread_get_extra_data());
}
-JavaContext* JavaContextFactory::create_context(
- std::function<void()> code,
- void_pfn_smxprocess_t cleanup, smx_actor_t process)
+JavaContext* JavaContextFactory::create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup_fun,
+ smx_actor_t actor)
{
- return this->new_context<JavaContext>(std::move(code), cleanup, process);
+ return this->new_context<JavaContext>(std::move(code), cleanup_fun, actor);
}
void JavaContextFactory::run_all()
/* If the user provided a function for the process then use it otherwise is the context for maestro */
if (has_code()) {
- this->jprocess = nullptr;
this->begin = xbt_os_sem_init(0);
this->end = xbt_os_sem_init(0);
std::throw_with_nested(std::move(new_exception));
}
} else {
- this->thread = nullptr;
xbt_os_thread_set_extra_data(this);
}
}
"Try using --cfg=contexts/factory:thread instead.\n");
}
-Context::Context(std::function<void()> code,
- void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
- : code_(std::move(code)), process_(process), iwannadie(false)
+Context::Context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor)
+ : code_(std::move(code)), actor_(actor)
{
/* If the user provided a function for the process then use it.
Otherwise, it is the context for maestro and we should set it as the
void Context::stop()
{
if (this->cleanup_func_)
- this->cleanup_func_(this->process_);
- this->process_->suspended_ = 0;
+ this->cleanup_func_(this->actor_);
+ this->actor_->suspended_ = 0;
this->iwannadie = false;
- simgrid::simix::simcall([this] { SIMIX_process_cleanup(this->process_); });
+ simgrid::simix::simcall([this] { SIMIX_process_cleanup(this->actor_); });
this->iwannadie = true;
}
private:
std::function<void()> code_;
void_pfn_smxprocess_t cleanup_func_ = nullptr;
- smx_actor_t process_ = nullptr;
+ smx_actor_t actor_ = nullptr;
public:
class StopRequest {
private:
std::string msg_;
};
- bool iwannadie;
+ bool iwannadie = false;
Context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process);
Context(const Context&) = delete;
void operator()() { code_(); }
bool has_code() const { return static_cast<bool>(code_); }
- smx_actor_t process() { return this->process_; }
+ smx_actor_t process() { return this->actor_; }
void set_cleanup(void_pfn_smxprocess_t cleanup) { cleanup_func_ = cleanup; }
// Virtual methods
class XBT_PUBLIC AttachContext : public Context {
public:
- AttachContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
- : Context(std::move(code), cleanup_func, process)
+ AttachContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor)
+ : Context(std::move(code), cleanup_func, actor)
{
}
// ThreadContext
-ThreadContext::ThreadContext(std::function<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t process,
- bool maestro)
- : AttachContext(std::move(code), cleanup, process), is_maestro_(maestro)
+ThreadContext::ThreadContext(std::function<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t actor, bool maestro)
+ : AttachContext(std::move(code), cleanup, actor), is_maestro_(maestro)
{
// We do not need the semaphores when maestro is in main,
// but creating them anyway simplifies things when maestro is externalized