1 /* Context switching within the JVM. */
3 /* Copyright (c) 2009-2022. 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"
23 class JavacontextFactory;
25 class JavaContext : public SerialThreadContext {
27 // The java process instance bound with the msg process structure:
28 jobject jprocess_ = nullptr;
29 // JNI interface pointer associated to this thread:
30 JNIEnv* jenv_ = nullptr;
32 friend class JavaContextFactory;
33 JavaContext(std::function<void()>&& code, actor::ActorImpl* actor);
35 void start_hook() override;
39 class JavaContextFactory : public ContextFactory {
42 ~JavaContextFactory() override;
43 Context* create_context(std::function<void()>&& code, actor::ActorImpl* actor) override;
44 void run_all(std::vector<actor::ActorImpl*> const& actors) override;
47 XBT_PRIVATE ContextFactory* java_factory();
48 XBT_PRIVATE void java_main_jprocess(jobject process);
50 } // namespace context
52 } // namespace simgrid
54 #endif /* SIMGRID_JAVA_JAVA_CONTEXT_HPP */