MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / ThreadPoolManager

Class ThreadPoolManager

src/ThreadPool.h:33–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31class ThreadArg;
32
33class ThreadPoolManager {
34
35public:
36 enum Flags {
37 VERBOSE = 1
38 };
39
40 static void init(unsigned int max_threads, unsigned int flags = 0) {
41 assert(instance == NULL);
42 instance = new ThreadPoolManager(max_threads, flags);
43 }
44
45 static ThreadPoolManager* getInstance() {
46 return instance;
47 }
48
49 bool reserveOneThread();
50 void releaseOneThread();
51 unsigned int getMaxThreads() const {return max_threads;}
52 unsigned int getFlags() const {return flags;}
53
54 bool isMainThread() const {return pthread_self() == main_pthread;}
55
56 ThreadPool* newThreadPool(const std::string& name);
57
58 void lock() const;
59 void unlock() const;
60
61private:
62 static ThreadPoolManager* instance;
63
64 unsigned int max_threads;
65 unsigned int flags;
66 unsigned int available_threads;
67 mutable pthread_mutex_t mp;
68 pthread_t main_pthread;
69
70 ThreadPoolManager(unsigned int max_threads, unsigned int flags = 0);
71};
72
73class Thread {
74 static const int WAIT_USECONDS = 50000;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected