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 
10 #pragma once
11 
12 #include "syncqueue.h"
13 
14 #include <functional>
15 #include <memory>
16 #include <thread>
17 
18 namespace yage
19 {
20 
21 class Active
22 {
23 public:
24  typedef std::function<void()> Callback;
25 
26  Active(const Active &) = delete;
27  Active &operator=(const Active &) = delete;
28 
29  ~Active();
30 
31  static std::unique_ptr<Active> create();
32 
33  void send(Callback message);
34 
35 private:
36  Active();
37  void run();
38 
39  bool running_;
40  SyncQueue<Callback> queue_;
41  std::thread thread_;
42 };
43 
44 } // namespace yage
void send(Callback message)
Definition: active.cpp:32
Definition: active.h:21
std::function< void()> Callback
Definition: active.h:24
Active & operator=(const Active &)=delete
~Active()
Definition: active.cpp:17
static std::unique_ptr< Active > create()
Definition: active.cpp:23
-*- c++ -*-