diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-04-25 19:33:58 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-04-25 19:33:58 +0200 |
commit | 75cb0b9dd64be0feff5cafc662b6cef76de128ce (patch) | |
tree | d209fe82bef32bedb80dd957f5042fc7eeb0d6e7 /CommonLibs | |
parent | 46324d3597f990526512c46f40a6d763fa86e7aa (diff) |
Move duplicated thread_enable_cancel to CommonLibs
Change-Id: I1a479b59bdda01233273dfa919bd678edbe34708
Diffstat (limited to 'CommonLibs')
-rw-r--r-- | CommonLibs/Threads.cpp | 6 | ||||
-rw-r--r-- | CommonLibs/Threads.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/CommonLibs/Threads.cpp b/CommonLibs/Threads.cpp index 2988e12..c056d69 100644 --- a/CommonLibs/Threads.cpp +++ b/CommonLibs/Threads.cpp @@ -122,6 +122,12 @@ void set_selfthread_name(const char *name) } } +void thread_enable_cancel(bool cancel) +{ + cancel ? pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) : + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); +} + void Thread::start(void *(*task)(void*), void *arg) { assert(mThread==((pthread_t)0)); diff --git a/CommonLibs/Threads.h b/CommonLibs/Threads.h index 3b76985..4c5b9ee 100644 --- a/CommonLibs/Threads.h +++ b/CommonLibs/Threads.h @@ -142,6 +142,7 @@ class Signal { thread.start((void *(*)(void*))function, (void*)argument); void set_selfthread_name(const char *name); +void thread_enable_cancel(bool cancel); /** A C++ wrapper for pthread threads. */ class Thread { |