X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dccf1b41e9c7b5a696f01abceaa2779fe65f154f..c68caf0f27b0fdde9df0a39857e5a162fc196d85:/src/bindings/java/JavaContext.hpp diff --git a/src/bindings/java/JavaContext.hpp b/src/bindings/java/JavaContext.hpp index a1a7ba16e6..5458cc1461 100644 --- a/src/bindings/java/JavaContext.hpp +++ b/src/bindings/java/JavaContext.hpp @@ -1,5 +1,6 @@ -/* Copyright (c) 2009-2010, 2012-2014. The SimGrid Team. - * All rights reserved. */ +/* Context switching within the JVM. */ + +/* Copyright (c) 2009-2018. 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. */ @@ -8,17 +9,14 @@ #define SIMGRID_JAVA_JAVA_CONTEXT_HPP #include - #include -#include -#include -#include - -#include "src/simix/smx_private.h" +#include "simgrid/simix.h" +#include "src/kernel/context/ContextThread.hpp" +#include "src/simix/smx_private.hpp" +#include "xbt/xbt_os_thread.h" -#include "jmsg.h" -#include "jmsg_process.h" +#include "jmsg.hpp" namespace simgrid { namespace kernel { @@ -27,35 +25,26 @@ namespace context { class JavaContext; class JavacontextFactory; -class JavaContext : public simgrid::kernel::context::Context { +class JavaContext : public simgrid::kernel::context::SerialThreadContext { public: // The java process instance bound with the msg process structure: - jobject jprocess = nullptr; + jobject jprocess_ = nullptr; // JNI interface pointer associated to this thread: - JNIEnv *jenv = nullptr; - xbt_os_thread_t thread = nullptr; - // Sempahore used to schedule/yield the process: - xbt_os_sem_t begin = nullptr; - // Semaphore used to schedule/unschedule the process: - xbt_os_sem_t end = nullptr; -public: + JNIEnv* jenv_ = nullptr; + friend class JavaContextFactory; JavaContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process); - ~JavaContext() override; + + 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 { 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;