summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-05-13 20:49:12 +0000
committerDavid Robillard <d@drobilla.net>2009-05-13 20:49:12 +0000
commit1e8949d592e1a5ad9ffd1dcb0e0157df7be8aa90 (patch)
treebed99ce8ea62c9ee846c4902a464c8939e14d981 /src
parentd7c463efcc0ed0085266afdc94458f24b273313d (diff)
downloadraul-1e8949d592e1a5ad9ffd1dcb0e0157df7be8aa90.tar.gz
raul-1e8949d592e1a5ad9ffd1dcb0e0157df7be8aa90.tar.bz2
raul-1e8949d592e1a5ad9ffd1dcb0e0157df7be8aa90.zip
Clean up Jack shutdown semantics.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@2003 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/Thread.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Thread.cpp b/src/Thread.cpp
index 1d965ad..6f683bf 100644
--- a/src/Thread.cpp
+++ b/src/Thread.cpp
@@ -33,6 +33,7 @@ Thread::Thread(const string& name)
, _context(0)
, _name(name)
, _pthread_exists(false)
+ , _own_thread(true)
{
pthread_once(&_thread_key_once, thread_key_alloc);
pthread_setspecific(_thread_key, this);
@@ -45,6 +46,7 @@ Thread::Thread(pthread_t thread, const string& name)
, _context(0)
, _name(name)
, _pthread_exists(true)
+ , _own_thread(false)
, _pthread(thread)
{
pthread_once(&_thread_key_once, thread_key_alloc);
@@ -89,9 +91,12 @@ void
Thread::stop()
{
if (_pthread_exists) {
- _exit_flag = true;
- pthread_cancel(_pthread);
- pthread_join(_pthread, NULL);
+ if (_own_thread) {
+ _exit_flag = true;
+ pthread_cancel(_pthread);
+ pthread_join(_pthread, NULL);
+ }
+ _pthread = NULL;
_pthread_exists = false;
cout << "[" << _name << " Thread] Exiting." << endl;
}