mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-16 01:21:20 +01:00
somewhere in between.. next step include generalData pointer in listerner and dataprocessor calss in constructor and a setter
This commit is contained in:
@@ -17,20 +17,20 @@ ThreadObject::ThreadObject(int ind):
|
||||
alive(false),
|
||||
killThread(false),
|
||||
thread(0) {
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||
PrintMembers();
|
||||
}
|
||||
|
||||
|
||||
ThreadObject::~ThreadObject() {
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||
DestroyThread();
|
||||
}
|
||||
|
||||
|
||||
void ThreadObject::PrintMembers() {
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
FILE_LOG(logDEBUG) << "Index : " << index
|
||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||
FILE_LOG (logDEBUG) << "Index : " << index
|
||||
<< "\nalive: " << alive
|
||||
<< "\nkillThread: " << killThread
|
||||
<< "\npthread: " << thread;
|
||||
@@ -38,7 +38,7 @@ void ThreadObject::PrintMembers() {
|
||||
|
||||
|
||||
void ThreadObject::DestroyThread() {
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||
if(alive){
|
||||
killThread = true;
|
||||
sem_post(&semaphore);
|
||||
@@ -46,40 +46,40 @@ void ThreadObject::DestroyThread() {
|
||||
sem_destroy(&semaphore);
|
||||
killThread = false;
|
||||
alive = false;
|
||||
FILE_LOG(logDEBUG) << GetType() << " thread with index " << index << " destroyed successfully.";
|
||||
FILE_LOG (logDEBUG) << GetType() << " thread with index " << index << " destroyed successfully.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ThreadObject::CreateThread() {
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||
if(alive){
|
||||
FILE_LOG(logERROR) << "Cannot create thread " << index << ". Already alive";
|
||||
FILE_LOG (logERROR) << "Cannot create thread " << index << ". Already alive";
|
||||
return FAIL;
|
||||
}
|
||||
sem_init(&semaphore,1,0);
|
||||
killThread = false;
|
||||
|
||||
if(pthread_create(&thread, NULL,StartThread, (void*) this)){
|
||||
FILE_LOG(logERROR) << "Could not create " << GetType() << " thread with index " << index;
|
||||
FILE_LOG (logERROR) << "Could not create " << GetType() << " thread with index " << index;
|
||||
return FAIL;
|
||||
}
|
||||
alive = true;
|
||||
FILE_LOG(logINFO) << GetType() << " thread " << index << " created successfully.";
|
||||
FILE_LOG (logINFO) << GetType() << " thread " << index << " created successfully.";
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
void* ThreadObject::StartThread(void* thisPointer) {
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||
((ThreadObject*)thisPointer)->RunningThread();
|
||||
return thisPointer;
|
||||
}
|
||||
|
||||
|
||||
void ThreadObject::RunningThread() {
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||
|
||||
|
||||
while(true) {
|
||||
|
||||
Reference in New Issue
Block a user