From 75cb0b9dd64be0feff5cafc662b6cef76de128ce Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 25 Apr 2019 19:33:58 +0200 Subject: [PATCH] Move duplicated thread_enable_cancel to CommonLibs Change-Id: I1a479b59bdda01233273dfa919bd678edbe34708 --- CommonLibs/Threads.cpp | 6 ++++++ CommonLibs/Threads.h | 1 + Transceiver52M/device/lms/LMSDevice.cpp | 6 ------ Transceiver52M/device/uhd/UHDDevice.cpp | 6 ------ 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/CommonLibs/Threads.cpp b/CommonLibs/Threads.cpp index 2988e122..c056d697 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 3b769854..4c5b9ee9 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 { diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp index b924fa7f..0cd41d31 100644 --- a/Transceiver52M/device/lms/LMSDevice.cpp +++ b/Transceiver52M/device/lms/LMSDevice.cpp @@ -90,12 +90,6 @@ static void lms_log_callback(int lvl, const char *msg) LOGLV(DLMS, lvl_map[lvl]) << msg; } -static void thread_enable_cancel(bool cancel) -{ - cancel ? pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) : - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); -} - static void print_range(const char* name, lms_range_t *range) { LOGC(DDEV, INFO) << name << ": Min=" << range->min << " Max=" << range->max diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp index 765150fb..46284e56 100644 --- a/Transceiver52M/device/uhd/UHDDevice.cpp +++ b/Transceiver52M/device/uhd/UHDDevice.cpp @@ -357,12 +357,6 @@ void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg) } #endif -static void thread_enable_cancel(bool cancel) -{ - cancel ? pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) : - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); -} - uhd_device::uhd_device(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chans, double lo_offset, const std::vector& tx_paths,