X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/15311a88748c43e1cce725bbfca20ea95e9debea..5ed37babb2fa9097abe82df299c0aa259ed84d5a:/src/bindings/java/JavaContext.hpp diff --git a/src/bindings/java/JavaContext.hpp b/src/bindings/java/JavaContext.hpp index 2724033d4b..83dc9e1590 100644 --- a/src/bindings/java/JavaContext.hpp +++ b/src/bindings/java/JavaContext.hpp @@ -1,6 +1,6 @@ /* Context switching within the JVM. */ -/* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -11,56 +11,39 @@ #include #include -#include "simgrid/simix.h" -#include "src/simix/smx_private.hpp" -#include "xbt/xbt_os_thread.h" +#include "src/kernel/context/ContextThread.hpp" #include "jmsg.hpp" -namespace simgrid { -namespace kernel { -namespace context { +namespace simgrid::kernel::context { class JavaContext; class JavacontextFactory; -class JavaContext : public simgrid::kernel::context::Context { +class JavaContext : public SerialThreadContext { public: // The java process instance bound with the msg process structure: jobject jprocess_ = nullptr; // JNI interface pointer associated to this thread: JNIEnv* jenv_ = nullptr; - xbt_os_thread_t thread_ = nullptr; - // Sempahore used to schedule/yield to the process: - xbt_os_sem_t begin_ = nullptr; - // Semaphore used to schedule/unschedule the process: - xbt_os_sem_t end_ = nullptr; friend class JavaContextFactory; - JavaContext(std::function code, - void_pfn_smxprocess_t cleanup_func, - smx_actor_t process); - ~JavaContext() override; + JavaContext(std::function&& code, actor::ActorImpl* actor); + + void start_hook() override; void stop() override; - void suspend() override; - void resume(); -private: - static void* wrapper(void *data); }; -class JavaContextFactory : public simgrid::kernel::context::ContextFactory { +class JavaContextFactory : public ContextFactory { public: JavaContextFactory(); ~JavaContextFactory() override; - JavaContext* self() override; - JavaContext* create_context(std::function code, - void_pfn_smxprocess_t, smx_actor_t process) override; - void run_all() override; + Context* create_context(std::function&& code, actor::ActorImpl* actor) override; + void run_all(std::vector const& actors) override; }; -XBT_PRIVATE simgrid::kernel::context::ContextFactory* java_factory(); XBT_PRIVATE void java_main_jprocess(jobject process); -}}} // namespace simgrid::kernel::context +} // namespace simgrid::kernel::context -#endif /* !_XBT_CONTEXT_JAVA_H */ +#endif /* SIMGRID_JAVA_JAVA_CONTEXT_HPP */