This is Unofficial EPICS BASE Doxygen Site
tpool.h
Go to the documentation of this file.
1 #ifndef TPOOL_H
2 #define TPOOL_H
3 
4 #include <stdexcept>
5 #include <deque>
6 #include <vector>
7 #include <string>
8 
9 #include <errlog.h>
10 #include <epicsThread.h>
11 #include <epicsMutex.h>
12 #include <epicsEvent.h>
13 
14 #include <pv/sharedPtr.h>
15 
16 #include <shareLib.h>
17 
18 struct WorkQueue : private epicsThreadRunable
19 {
20  typedef std::tr1::weak_ptr<epicsThreadRunable> value_type;
21 
22 private:
23  const std::string name;
24 
25  epicsMutex mutex;
26 
27  enum state_t {
28  Idle,
29  Active,
30  Stopping,
31  } state;
32 
33  typedef std::deque<value_type> queue_t;
34  queue_t queue;
35 
36  epicsEvent wakeup;
37 
38  typedef std::vector<epicsThread*> workers_t;
39  workers_t workers;
40 
41 public:
42  WorkQueue(const std::string& name);
43  virtual ~WorkQueue();
44 
45  void start(unsigned nworkers=1, unsigned prio = epicsThreadPriorityLow);
46  void close();
47 
48  void add(const value_type& work);
49 
50 private:
51  virtual void run();
52 };
53 
54 #endif // TPOOL_H
virtual ~WorkQueue()
Definition: tpool.cpp:23
std::tr1::weak_ptr< epicsThreadRunable > value_type
Definition: tpool.h:20
void close()
Definition: tpool.cpp:52
WorkQueue(const std::string &name)
Definition: tpool.cpp:18
Mark external symbols and entry points for shared libraries.
void add(const value_type &work)
Definition: tpool.cpp:79
APIs for the epicsMutex mutual exclusion semaphore.
#define epicsThreadPriorityLow
Definition: epicsThread.h:75
APIs for the epicsEvent binary semaphore.
C++ and C descriptions for a thread.
void start(unsigned nworkers=1, unsigned prio=epicsThreadPriorityLow)
Definition: tpool.cpp:25