Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
oups, forgot to adapt MC to my last change in config
[simgrid.git] / src / simix / ThreadContext.hpp
index f0655b1..abed187 100644 (file)
@@ -18,24 +18,29 @@ namespace simix {
 class ThreadContext;
 class ThreadContextFactory;
 
-class ThreadContext : public Context {
+class ThreadContext : public AttachContext {
 public:
   friend ThreadContextFactory;
   ThreadContext(std::function<void()> 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<void()> code, smx_process_t process) override;
 };
 
 }