CARMA C++
Runnable.h
1 // $Id: Runnable.h,v 1.2 2011/02/25 01:23:45 eml Exp $
2 
3 #ifndef SZA_UTIL_RUNNABLE_H
4 #define SZA_UTIL_RUNNABLE_H
5 
15 #include "carma/szautil/Thread.h"
16 
17 #define RUN_FN(fn) void* (fn)(void* arg)
18 
19 namespace sza {
20  namespace util {
21 
22  class Runnable {
23  public:
24 
28  Runnable(bool spawnThread, RUN_FN(*runFn));
29 
33  virtual ~Runnable();
34 
38  static THREAD_START(startUp);
39 
40  static void blockForever();
41 
42  protected:
43 
48  Thread* spawnedThread_;
49 
53  bool spawned_;
54 
55  // A pointer to a function which will be called on startup
56 
57  RUN_FN(*runFn_);
58 
59  void spawn(void* arg);
60 
61  public:
62 
63  virtual void spawn();
64 
65  }; // End class Runnable
66 
67  } // End namespace util
68 } // End namespace sza
69 
70 
71 
72 #endif // End #ifndef SZA_UTIL_RUNNABLE_H
Tagged: Fri Nov 14 12:39:37 UTC 2003.