YAGE  v0.1.1
Yet Another Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
active.h
Go to the documentation of this file.
1 #ifndef YAGE_UTIL_ACTIVE_H
2 #define YAGE_UTIL_ACTIVE_H
3 
4 #include "syncqueue.h"
5 
6 #include <functional>
7 #include <memory>
8 #include <thread>
9 
10 namespace yage
11 {
12 
13 class Active
14 {
15 public:
16  typedef std::function<void()> Callback;
17 
18  Active(const Active &) = delete;
19  Active &operator=(const Active &) = delete;
20 
21  ~Active();
22 
23  static std::unique_ptr<Active> create();
24 
25  void send(Callback message);
26 
27 private:
28  Active();
29  void run();
30 
31  bool running_;
33  std::thread thread_;
34 };
35 
36 } // namespace yage
37 
38 #endif
void run()
Definition: active.cpp:36
void send(Callback message)
Definition: active.cpp:31
Definition: active.h:13
std::function< void()> Callback
Definition: active.h:16
Active & operator=(const Active &)=delete
Active()
Definition: active.cpp:14
~Active()
Definition: active.cpp:16
std::thread thread_
Definition: active.h:33
static std::unique_ptr< Active > create()
Definition: active.cpp:22
bool running_
Definition: active.h:31
SyncQueue< Callback > queue_
Definition: active.h:32