YAPOG  0.0.1
Yet Another Pokemon Online Game
Thread.hpp
Go to the documentation of this file.
1 #ifndef YAPOG_THREAD_HPP
2 # define YAPOG_THREAD_HPP
3 
4 # include <functional>
5 
6 # include <SFML/System.hpp>
7 
8 # include "YAPOG/Macros.hpp"
10 
11 # define MEMBER_WORKER(MEMBER) \
12  std::bind (&MEMBER, this, std::placeholders::_1)
13 
14 namespace yap
15 {
16  typedef sf::Mutex Mutex;
17  typedef sf::Lock Lock;
18 
20  {
22 
23  public:
24 
25  typedef std::function<void (void)> WorkerType;
26 
27  explicit Thread (WorkerType worker);
28 
29  template <typename FunctionType, typename ArgsType>
30  Thread (FunctionType function, ArgsType args);
31 
32  void Launch ();
33  void Stop ();
34 
35  void Wait ();
36 
37  static void Sleep (const Time& delay);
38 
39  private:
40 
41  sf::Thread thread_;
42  };
43 } // namespace yap
44 
46 
47 #endif // YAPOG_THREAD_HPP