aboutsummaryrefslogtreecommitdiff
path: root/utils/src
diff options
context:
space:
mode:
authorHo-Eun Ryu <ho-eun.ryu@windriver.com>2009-09-25 14:53:52 +0900
committerPatrick Tjin <pattjin@google.com>2014-07-21 22:03:24 -0700
commitc27c32fcf90773a9468cd827d9e118630dd51e87 (patch)
tree9c1e21974a6d8622373576f4e762d8523f2b1903 /utils/src
parenteb6dc073efaf0a75eb85ddf39819e9c431ac10e4 (diff)
downloadwrs_omxil_core-c27c32fcf90773a9468cd827d9e118630dd51e87.tar.gz
utils:thread: fix bug, pthread create/join
this patch prevent Start() from creating new thread without Join() and join() from joining a thread not created yet.
Diffstat (limited to 'utils/src')
-rw-r--r--utils/src/thread.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/utils/src/thread.cpp b/utils/src/thread.cpp
index 9b096c4..17f70d9 100644
--- a/utils/src/thread.cpp
+++ b/utils/src/thread.cpp
@@ -4,6 +4,7 @@
Thread::Thread()
{
r = NULL;
+ created = false;
}
Thread::Thread(RunnableInterface *r)
@@ -18,12 +19,27 @@ Thread::~Thread()
int Thread::Start(void)
{
- return pthread_create(&id, NULL, Instance, this);
+ int ret = 0;
+
+ if (!created) {
+ ret = pthread_create(&id, NULL, Instance, this);
+ if (!ret)
+ created = true;
+ }
+
+ return ret;
}
int Thread::Join(void)
{
- return pthread_join(id, NULL);
+ int ret = 0;
+
+ if (created) {
+ ret = pthread_join(id, NULL);
+ created = false;
+ }
+
+ return ret;
}
void *Thread::Instance(void *p)