- UContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process);
- ~UContext() override;
- void stop() override;
- virtual void resume() = 0;
-
- static void swap(UContext* from, UContext* to) { swapcontext(&from->uc_, &to->uc_); }
- static UContext* getMaestro() { return maestro_context_; }
- static void setMaestro(UContext* maestro) { maestro_context_ = maestro; }
-
-private:
- static UContext* maestro_context_;
- void* stack_ = nullptr; /* the thread stack */
- ucontext_t uc_; /* the ucontext that executes the code */
-
- static void wrapper(int, int);
- static void make_ctx(ucontext_t* ucp, void (*func)(int, int), UContext* arg);
-};
-
-class SerialUContext : public UContext {
-public:
- SerialUContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
- : UContext(std::move(code), cleanup_func, process)
- {
- }
- void suspend() override;
- void resume() override;
-
- static void run_all();