Oxygine  1
2g game engine
ThreadLoader.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "EventDispatcher.h"
4 #include "pthread.h"
5 #include "core/ThreadDispatcher.h"
6 #include <functional>
7 #include "Event.h"
8 
9 namespace oxygine
10 {
11  DECLARE_SMART(ThreadLoader, spThreadLoader);
13  {
14  public:
15  enum
16  {
17  COMPLETE = Event::COMPLETE,
18  };
19 
20  ThreadLoader();
21  ~ThreadLoader();
22 
23  bool isCompleted();
24 
25  virtual void add(Resources* res);
26  virtual void add(Resource* res);
27 
28 #ifndef __S3E__
29  virtual void add(std::function< void() >);
30 #endif
31 
32  void start();
33  //void stop();
34 
36  void load();
37  void unload();
38 
39  private:
40  static void* _staticThreadFunc(void* t);
41  static void threadDone(const ThreadDispatcher::message& msg);
42  virtual void _threadFunc();
43 
44  void loaded(Event*);
45  void _load();
46 
47  pthread_t _thread;
48  volatile bool _threadDone;
49 
50  typedef std::list<Resources*> resources;
51  resources _resources;
52 
53  typedef std::list<Resource*> ress;
54  ress _ress;
55 
56 #ifndef __S3E__
57  typedef std::list<std::function<void()> > funcs;
58  funcs _funcs;
59 #endif
60  };
61 }
Definition: Event.h:10
–oxgl-end–!
Definition: Actor.h:14
Definition: ThreadLoader.h:12
Definition: Resource.h:10
Definition: ThreadDispatcher.h:50
Definition: EventDispatcher.h:27
Definition: Resources.h:43