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

Method run

src/ThreadPool.cpp:76–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void ThreadPool::run()
77{
78 std::vector<Thread*>::iterator begin = thread_list.begin();
79 std::vector<Thread*>::iterator end = thread_list.end();
80 std::map<Thread*, bool> thread_map;
81
82 bool mono_thread = thread_list.size() == 1;
83 unsigned int thread_num = 1;
84 time_t t0 = time(NULL);
85 if (thrPoolManager->getFlags() & ThreadPoolManager::VERBOSE) {
86 thrPoolManager->lock();
87 std::cout << "Thread pool [" << getName() << "] started [" << thread_list.size() << " threads]\n";
88 thrPoolManager->unlock();
89 }
90
91 do {
92 Thread* thread = *begin++;
93 pthread_t tid = 0;
94 if (mono_thread) {
95 ThreadPool::wrapper(thread);
96 } else {
97 pthread_create(&tid, NULL, ThreadPool::wrapper, thread);
98 }
99 if (thrPoolManager->getFlags() & ThreadPoolManager::VERBOSE) {
100 thrPoolManager->lock();
101 std::cout << "Thread launched [" << getName() << "#" << thread_num << ":" << tid << "] at [" << (time(NULL) - t0) << " secs]" << std::endl;
102 thrPoolManager->unlock();
103 }
104 thread_map[thread] = true;
105 while (!thrPoolManager->reserveOneThread()) {
106 checkOneThreadFinished(thread_map);
107 }
108 thread_num++;
109 } while (begin != end);
110
111 wait(thread_map);
112
113 if (thrPoolManager->getFlags() & ThreadPoolManager::VERBOSE) {
114 thrPoolManager->lock();
115 std::cout << "Thread pool [" << getName() << "] terminated" << std::endl;
116 thrPoolManager->unlock();
117 }
118}
119
120void ThreadPool::checkOneThreadFinished(std::map<Thread*, bool>& thread_map)
121{

Callers 4

calculateBreakpointsMethod · 0.80
mainFunction · 0.80
runWithDefinedPloidyFunction · 0.80

Calls 4

getFlagsMethod · 0.80
lockMethod · 0.80
unlockMethod · 0.80
reserveOneThreadMethod · 0.80

Tested by

no test coverage detected