JavaContextFactory::~JavaContextFactory()=default;
-JavaContext* JavaContextFactory::self()
-{
- return static_cast<JavaContext*>(xbt_os_thread_get_extra_data());
-}
-
JavaContext* JavaContextFactory::create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup_fun,
smx_actor_t actor)
{
void JavaContext::start_hook()
{
- xbt_os_thread_set_extra_data(this); // We need to attach it also for maestro, in contrary to our ancestor
+ SIMIX_context_set_current(this); // We need to attach it also for maestro, in contrary to our ancestor
//Attach the thread to the JVM
JNIEnv *env;
public:
JavaContextFactory();
~JavaContextFactory() override;
- JavaContext* self() override;
JavaContext* create_context(std::function<void()> code,
void_pfn_smxprocess_t, smx_actor_t process) override;
void run_all() override;
JNIEnv *get_current_thread_env()
{
using simgrid::kernel::context::JavaContext;
- JavaContext* ctx = static_cast<JavaContext*>(xbt_os_thread_get_extra_data());
+ JavaContext* ctx = static_cast<JavaContext*>(SIMIX_context_self());
return ctx->jenv_;
}
virtual void run_all() = 0;
/** @brief Returns the current context of this thread. */
- virtual Context* self();
+ Context* self();
std::string const& name() const { return name_; }
protected:
/* Otherwise, we attach to the current thread */
else {
- xbt_os_thread_set_extra_data(this);
+ SIMIX_context_set_current(this);
}
}
void *ThreadContext::wrapper(void *param)
{
ThreadContext* context = static_cast<ThreadContext*>(param);
+ SIMIX_context_set_current(context);
#ifndef WIN32
/* Install alternate signal stack, for SIGSEGV handler. */
ThreadContext* maestro = (ThreadContext*)simix_global->maestro_process->context_;
maestro->end_.acquire();
- xbt_os_thread_set_extra_data(nullptr);
+ SIMIX_context_set_current(nullptr);
}
// SerialThreadContext
return create_context(std::move(code), cleanup_func, process, maestro);
}
void run_all() override;
- ThreadContext* self() override { return static_cast<ThreadContext*>(xbt_os_thread_get_extra_data()); }
// Optional methods:
ThreadContext* attach(void_pfn_smxprocess_t cleanup_func, smx_actor_t process) override