mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Merge branch '3.0.1' into developer
This commit is contained in:
commit
d2319459df
@ -300,9 +300,8 @@ multiSlsDetector::~multiSlsDetector() {
|
|||||||
|
|
||||||
|
|
||||||
int multiSlsDetector::createThreadPool(){
|
int multiSlsDetector::createThreadPool(){
|
||||||
if(threadpool){
|
if(threadpool)
|
||||||
threadpool->destroy_threadpool();
|
destroyThreadPool();
|
||||||
}
|
|
||||||
int numthreads = thisMultiDetector->numberOfDetectors;
|
int numthreads = thisMultiDetector->numberOfDetectors;
|
||||||
if(numthreads < 1){
|
if(numthreads < 1){
|
||||||
numthreads = 1; //create threadpool anyway, threads initialized only when >1 detector added
|
numthreads = 1; //create threadpool anyway, threads initialized only when >1 detector added
|
||||||
@ -328,7 +327,6 @@ int multiSlsDetector::createThreadPool(){
|
|||||||
|
|
||||||
void multiSlsDetector::destroyThreadPool(){
|
void multiSlsDetector::destroyThreadPool(){
|
||||||
if(threadpool){
|
if(threadpool){
|
||||||
threadpool->destroy_threadpool();
|
|
||||||
delete threadpool;
|
delete threadpool;
|
||||||
threadpool=0;
|
threadpool=0;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
@ -7,7 +7,7 @@ Mutex::Mutex() {
|
|||||||
|
|
||||||
Mutex::~Mutex() {
|
Mutex::~Mutex() {
|
||||||
while(is_locked);
|
while(is_locked);
|
||||||
unlock(); // Unlock Mutex after shared resource is safe
|
//unlock(); // Unlock Mutex after shared resource is safe
|
||||||
pthread_mutex_destroy(&m_lock);
|
pthread_mutex_destroy(&m_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "ThreadPool.h"
|
#include "ThreadPool.h"
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
ThreadPool::ThreadPool(int pool_size) : m_pool_size(pool_size){
|
ThreadPool::ThreadPool(int pool_size) : m_pool_size(pool_size){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -62,24 +62,29 @@ int ThreadPool::destroy_threadpool(){
|
|||||||
//to other threads until its modified in a lock!
|
//to other threads until its modified in a lock!
|
||||||
m_task_mutex.lock();
|
m_task_mutex.lock();
|
||||||
m_pool_state = STOPPED;
|
m_pool_state = STOPPED;
|
||||||
m_task_mutex.unlock();
|
|
||||||
/*cout << "Broadcasting STOP signal to all threads..." << endl;*/
|
/*cout << "Broadcasting STOP signal to all threads..." << endl;*/
|
||||||
m_task_cond_var.broadcast(); // notify all threads we are shttung down
|
m_task_cond_var.broadcast(); // notify all threads we are shttung down
|
||||||
|
m_task_mutex.unlock();
|
||||||
|
|
||||||
// int ret = -1;
|
// int ret = -1;
|
||||||
for (int i = 0; i < m_pool_size; i++) {
|
for (int i = 0; i < m_pool_size; i++) {
|
||||||
void* result;
|
|
||||||
sem_post(&semStart);
|
sem_post(&semStart);
|
||||||
sem_post(&semDone);
|
sem_post(&semDone);
|
||||||
//ret =
|
|
||||||
|
void* result;
|
||||||
pthread_join(m_threads[i], &result);
|
pthread_join(m_threads[i], &result);
|
||||||
/*cout << "pthread_join() returned " << ret << ": " << strerror(errno) << endl;*/
|
/*cout << "pthread_join() returned " << ret << ": " << strerror(errno) << endl;*/
|
||||||
|
m_task_mutex.lock();
|
||||||
m_task_cond_var.broadcast(); // try waking up a bunch of threads that are still waiting
|
m_task_cond_var.broadcast(); // try waking up a bunch of threads that are still waiting
|
||||||
|
m_task_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sem_destroy(&semStart);
|
sem_destroy(&semStart);
|
||||||
sem_destroy(&semDone);
|
sem_destroy(&semDone);
|
||||||
number_of_ongoing_tasks = 0;
|
number_of_ongoing_tasks = 0;
|
||||||
number_of_total_tasks = 0;
|
number_of_total_tasks = 0;
|
||||||
|
|
||||||
/* cout << m_pool_size << " threads exited from the thread pool" << endl;*/
|
/* cout << m_pool_size << " threads exited from the thread pool" << endl;*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user