1 /* Context switching within the JVM. */
3 /* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #ifndef SIMGRID_JAVA_JAVA_CONTEXT_HPP
9 #define SIMGRID_JAVA_JAVA_CONTEXT_HPP
14 #include "src/kernel/context/ContextThread.hpp"
18 namespace simgrid::kernel::context {
21 class JavacontextFactory;
23 class JavaContext : public SerialThreadContext {
25 // The java process instance bound with the msg process structure:
26 jobject jprocess_ = nullptr;
27 // JNI interface pointer associated to this thread:
28 JNIEnv* jenv_ = nullptr;
30 friend class JavaContextFactory;
31 JavaContext(std::function<void()>&& code, actor::ActorImpl* actor);
33 void start_hook() override;
37 class JavaContextFactory : public ContextFactory {
40 ~JavaContextFactory() override;
41 Context* create_context(std::function<void()>&& code, actor::ActorImpl* actor) override;
42 void run_all(std::vector<actor::ActorImpl*> const& actors) override;
45 XBT_PRIVATE void java_main_jprocess(jobject process);
47 } // namespace simgrid::kernel::context
49 #endif /* SIMGRID_JAVA_JAVA_CONTEXT_HPP */