SLAMflex SE  0.1.0
SLAMflex provides detection and tracking of dominant planes for smartphone devices. This plane can then be used to show AR content relative to the plane orientation. The detection of plane is performed in the field of view of the smartphone camera. In subsequent frames it is tracked. The interface returns the plane position and orientation.
thread.h
Go to the documentation of this file.
1 #ifndef LIBSLAMFLEX_JNI_THREAD_H_
2 #define LIBSLAMFLEX_JNI_THREAD_H_
3 
4 //POSIX threads
5 #include "pthread.h"
6 #include "runnable.h"
7 
8 namespace CVD {
13 class Thread : public Runnable
14 {
15  public:
17  Thread();
18 
20  virtual ~Thread();
21 
23  void start(Runnable* runnable=0);
24 
26 
27  void stop();
28 
30  bool shouldStop() const;
31 
33  bool isRunning() const;
34 
36 
37  void join();
38 
40  pthread_t getID();
41 
43  virtual void run(){};
44 
45  //Static methods:
46 
48  static unsigned int count();
49 
51  static Thread* getCurrent();
52 
54  static void sleep(unsigned int milli);
55 
57  static void yield();
58 
59  private:
60  static bool init();
61  static bool ourInitializedFlag;
62  static void* threadproc(void* param);
63  static pthread_key_t ourKey;
64  static unsigned int ourCount;
66  pthread_t myID;
68  bool myStopFlag;
69 };
70 
71 }
72 #endif
Thread()
Construct a thread. If runnable != 0, use that runnable, else use our own "run" method.
Definition: thread.cpp:12
static bool init()
Definition: thread.cpp:91
pthread_t myID
Definition: thread.h:66
virtual void run()
Override this method to do whatever it is the thread should do.
Definition: thread.h:43
static void yield()
Tell the current thread to yield the processor.
void stop()
Tell the thread to stop.
Definition: thread.cpp:43
static unsigned int count()
Returns how many threads are actually running, not including the main thread.
Definition: thread.cpp:68
This is an abstract base class for anything with a run() method.
Definition: runnable.h:6
Definition: abs.h:24
Runnable * myRunnable
Definition: thread.h:65
void start(Runnable *runnable=0)
Start execution of "run" method in separate thread.
Definition: thread.cpp:32
static Thread * getCurrent()
Returns a pointer to the currently running thread.
Definition: thread.cpp:73
static void * threadproc(void *param)
Definition: thread.cpp:98
bool isRunning() const
Returns true if the thread is still running.
Definition: thread.cpp:53
static bool ourInitializedFlag
Definition: thread.h:61
static pthread_key_t ourKey
Definition: thread.h:63
pthread_t getID()
Get the ID of this thread.
Definition: thread.cpp:63
bool myStopFlag
Definition: thread.h:68
bool myRunningFlag
Definition: thread.h:67
bool shouldStop() const
Returns true if the stop() method been called, false otherwise.
Definition: thread.cpp:48
static unsigned int ourCount
Definition: thread.h:64
virtual ~Thread()
This does not destroy the object until the thread has been terminated.
Definition: thread.cpp:22
void join()
This blocks until the thread has actually terminated.
Definition: thread.cpp:58
static void sleep(unsigned int milli)
Tell the current thread to sleep for milli milliseconds.
Definition: thread.cpp:79