X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/be6e8d3215d3e25f48c7d2d0b359cf178f978d41..1398fa7c21c0d81f808108e0803d875c6fce9b8e:/src/simix/ThreadContext.hpp diff --git a/src/simix/ThreadContext.hpp b/src/simix/ThreadContext.hpp index f0655b1161..abed18789f 100644 --- a/src/simix/ThreadContext.hpp +++ b/src/simix/ThreadContext.hpp @@ -18,24 +18,29 @@ namespace simix { class ThreadContext; class ThreadContextFactory; -class ThreadContext : public Context { +class ThreadContext : public AttachContext { public: friend ThreadContextFactory; ThreadContext(std::function code, void_pfn_smxprocess_t cleanup_func, - smx_process_t process); + smx_process_t process, bool maestro =false); ~ThreadContext(); void stop() override; void suspend() override; + void attach_start() override; + void attach_stop() override; private: /** A portable thread */ - xbt_os_thread_t thread_; + xbt_os_thread_t thread_ = nullptr; /** Semaphore used to schedule/yield the process */ - xbt_os_sem_t begin_; + xbt_os_sem_t begin_ = nullptr; /** Semaphore used to schedule/unschedule */ - xbt_os_sem_t end_; + xbt_os_sem_t end_ = nullptr; private: static void* wrapper(void *param); + static void* maestro_wrapper(void *param); +public: + void start(); }; class ThreadContextFactory : public ContextFactory { @@ -46,6 +51,10 @@ public: void_pfn_smxprocess_t cleanup_func, smx_process_t process) override; void run_all() override; ThreadContext* self() override; + + // Optional methods: + ThreadContext* attach(void_pfn_smxprocess_t cleanup_func, smx_process_t process) override; + ThreadContext* create_maestro(std::function code, smx_process_t process) override; }; }