From 2a0095f2207169fe7192568d387746c008eabc10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20Hern=C3=A0ndez=20Juan?= <shernand@iri.upc.edu> Date: Wed, 11 Jun 2014 10:05:49 +0000 Subject: [PATCH] Added a function to get the status of the thread. --- src/threads/threadserver.cpp | 18 ++++++++++++++++++ src/threads/threadserver.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/threads/threadserver.cpp b/src/threads/threadserver.cpp index 90a2363..026ad40 100644 --- a/src/threads/threadserver.cpp +++ b/src/threads/threadserver.cpp @@ -195,3 +195,21 @@ void CThreadServer::detach_thread(const std::string& thread_id) thread->detach(); } } + +int CThreadServer::get_thread_state(const std::string &thread_id) +{ + std::list<CThread>::iterator thread; + + this->access_threads.enter(); + if((thread=this->search_thread(thread_id))==(std::list<CThread>::iterator)NULL) + { + this->access_threads.exit(); + /* handle exceptions */ + throw CThreadServerException(_HERE_,"Unknown thread",thread_id); + } + else + { + this->access_threads.exit(); + return thread->get_state(); + } +} diff --git a/src/threads/threadserver.h b/src/threads/threadserver.h index 3aa8be9..fe8f60a 100644 --- a/src/threads/threadserver.h +++ b/src/threads/threadserver.h @@ -314,6 +314,12 @@ class CThreadServer * must not have any spaces or special characters, and must be unique. */ void detach_thread(const std::string& thread_id); + + /** + * \brief + * + */ + int get_thread_state(const std::string &thread_id); }; #endif -- GitLab