1 /* Context switching within the JVM. */
3 /* Copyright (c) 2009-2019. 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 "simgrid/simix.h"
15 #include "src/kernel/context/ContextThread.hpp"
16 #include "src/simix/smx_private.hpp"
25 class JavacontextFactory;
27 class JavaContext : public simgrid::kernel::context::SerialThreadContext {
29 // The java process instance bound with the msg process structure:
30 jobject jprocess_ = nullptr;
31 // JNI interface pointer associated to this thread:
32 JNIEnv* jenv_ = nullptr;
34 friend class JavaContextFactory;
35 JavaContext(std::function<void()>&& code, smx_actor_t actor);
37 void start_hook() override;
38 void stop_hook() override;
41 class JavaContextFactory : public simgrid::kernel::context::ContextFactory {
44 ~JavaContextFactory() override;
45 JavaContext* create_context(std::function<void()>&& code, smx_actor_t actor) override;
46 void run_all() override;
49 XBT_PRIVATE simgrid::kernel::context::ContextFactory* java_factory();
50 XBT_PRIVATE void java_main_jprocess(jobject process);
52 }}} // namespace simgrid::kernel::context
54 #endif /* !_XBT_CONTEXT_JAVA_H */