My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Runnable.h
Go to the documentation of this file.
1 // $Id: Runnable.h,v 1.1.1.1 2009/07/06 23:57:26 eml Exp $
2 
3 #ifndef GCP_UTIL_RUNNABLE_H
4 #define GCP_UTIL_RUNNABLE_H
5 
15 #include "gcp/util/common/Thread.h"
16 #include "gcp/util/common/Exception.h"
17 
18 #define RUN_FN(fn) void* (fn)(void* arg)
19 
20 namespace gcp {
21  namespace util {
22 
23  class Runnable {
24  public:
25 
29  Runnable(bool spawnThread, RUN_FN(*runFn));
30 
31  Runnable(bool spawnThread, RUN_FN(*runFn), int priority);
32 
36  virtual ~Runnable();
37 
41  static THREAD_START(startUp);
42 
43  void blockForever();
44 
45  protected:
46 
47  virtual void broadcastReady()
48  {
50  }
51 
57 
61  bool spawned_;
62 
63  // A pointer to a function which will be called on startup
64 
65  RUN_FN(*runFn_);
66 
67  void spawn(void* arg);
68 
69  public:
70 
71  void spawn();
72 
73  }; // End class Runnable
74 
75  } // End namespace util
76 } // End namespace gcp
77 
78 
79 
80 
81 #endif // End #ifndef GCP_UTIL_RUNNABLE_H
bool spawned_
Definition: Runnable.h:61
virtual ~Runnable()
Definition: Runnable.cc:70
static THREAD_START(startUp)
Thread * spawnedThread_
Definition: Runnable.h:56
Runnable(bool spawnThread, RUN_FN(*runFn))
Definition: Runnable.cc:15
Definition: Thread.h:57
Definition: Runnable.h:23
void broadcastReady()
Definition: Thread.cc:348