diff options
Diffstat (limited to 'yage/util/active.h')
-rw-r--r-- | yage/util/active.h | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/yage/util/active.h b/yage/util/active.h index 877ab75e..ca8d30ad 100644 --- a/yage/util/active.h +++ b/yage/util/active.h @@ -1,11 +1,38 @@ #ifndef YAGE_UTIL_ACTIVE_H #define YAGE_UTIL_ACTIVE_H +#include "syncqueue.h" + +#include <functional> +#include <memory> +#include <thread> + +namespace yage +{ + class Active { public: + typedef std::function<void()> Callback; + + Active(const Active &) = delete; + Active &operator=(const Active &) = delete; + + ~Active(); + + static std::unique_ptr<Active> create(); + + void send(Callback message); + +private: Active(); - virtual ~Active(); + void run(); + + bool running_; + SyncQueue<Callback> queue_; + std::thread thread_; }; +} // namespace yage + #endif |