rxr: removed return ok or fail and replaced with exceptions

This commit is contained in:
2019-11-29 10:29:36 +01:00
parent 796890d1c8
commit 1d6be74ee5
20 changed files with 517 additions and 678 deletions

View File

@ -48,22 +48,18 @@ void ThreadObject::DestroyThread() {
}
int ThreadObject::CreateThread() {
if(alive){
FILE_LOG(logERROR) << "Cannot create thread " << index << ". Already alive";
return FAIL;
void ThreadObject::CreateThread() {
if (alive) {
throw sls::RuntimeError("Cannot create " + GetType() + " thread " + std::to_string(index) + ". Already alive");
}
sem_init(&semaphore,1,0);
killThread = false;
if(pthread_create(&thread, nullptr,StartThread, (void*) this)){
FILE_LOG(logERROR) << "Could not create " << GetType() << " thread with index " << index;
return FAIL;
if (pthread_create(&thread, nullptr,StartThread, (void*) this)){
throw sls::RuntimeError("Could not create " + GetType() + " thread with index " + std::to_string(index));
}
alive = true;
FILE_LOG(logDEBUG) << GetType() << " thread " << index << " created successfully.";
return OK;
}