- xbt_os_thread_t thread_ = nullptr;
- /** Semaphore used to schedule/yield the process */
- xbt_os_sem_t begin_ = nullptr;
- /** Semaphore used to schedule/unschedule */
- xbt_os_sem_t end_ = nullptr;
-private:
- static void* wrapper(void *param);
- static void* maestro_wrapper(void *param);
+ std::thread* thread_ = nullptr;
+ /** Semaphore used to schedule/yield the actor (not needed when the maestro is in main, but harmless then) */
+ xbt::OsSemaphore begin_{0};
+ /** Semaphore used to schedule/unschedule (not needed when the maestro is in main, but harmless then) */
+ xbt::OsSemaphore end_{0};
+ bool is_maestro_;
+
+ void start(); // match a call to release()
+ void yield(); // match a call to yield()
+ virtual void start_hook() { /* empty placeholder, called after start(). Used in parallel mode and Java */}
+ virtual void yield_hook() { /* empty placeholder, called before yield(). Used in parallel mode */}
+ virtual void stop_hook() { /* empty placeholder, called at stop(). Used in Java */}
+
+ static void wrapper(ThreadContext* context);
+};
+
+class XBT_PUBLIC SerialThreadContext : public ThreadContext {
+public:
+ SerialThreadContext(std::function<void()> code, smx_actor_t actor, bool maestro)
+ : ThreadContext(std::move(code), actor, maestro)
+ {
+ }
+
+ static void run_all();
+};
+
+class ParallelThreadContext : public ThreadContext {