X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ec575e854f16278a18a3c5993b7ec9d2aa5bdc0e..1398fa7c21c0d81f808108e0803d875c6fce9b8e:/src/simix/ThreadContext.hpp diff --git a/src/simix/ThreadContext.hpp b/src/simix/ThreadContext.hpp index 4ecd959a5e..abed18789f 100644 --- a/src/simix/ThreadContext.hpp +++ b/src/simix/ThreadContext.hpp @@ -18,37 +18,43 @@ namespace simix { class ThreadContext; class ThreadContextFactory; -class ThreadContext : public Context { +class ThreadContext : public AttachContext { public: friend ThreadContextFactory; - ThreadContext(xbt_main_func_t code, - int argc, char **argv, + 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 { public: ThreadContextFactory(); ~ThreadContextFactory(); - virtual ThreadContext* create_context( - xbt_main_func_t, int, char **, void_pfn_smxprocess_t, - smx_process_t process - ) override; + virtual ThreadContext* create_context(std::function code, + 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; }; }