#pragma once #include #include #include namespace gnu = __gnu_cxx; namespace Balau { class Task; class TaskMan { public: TaskMan(); ~TaskMan(); void mainLoop(); void stop() { stopped = true; } static TaskMan * getTaskMan(); private: void registerTask(Task * t); void unregisterTask(Task * t); coro_context returnContext; friend class Task; struct taskHash { size_t operator()(const Task * t) const { return reinterpret_cast(t); } }; typedef gnu::hash_set taskList; taskList tasks, pendingAdd; volatile bool stopped; }; };