Move duplicated thread_enable_cancel to CommonLibs

Change-Id: I1a479b59bdda01233273dfa919bd678edbe34708
This commit is contained in:
Pau Espin 2019-04-25 19:33:58 +02:00
parent 46324d3597
commit 75cb0b9dd6
4 changed files with 7 additions and 12 deletions

View File

@ -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) void Thread::start(void *(*task)(void*), void *arg)
{ {
assert(mThread==((pthread_t)0)); assert(mThread==((pthread_t)0));

View File

@ -142,6 +142,7 @@ class Signal {
thread.start((void *(*)(void*))function, (void*)argument); thread.start((void *(*)(void*))function, (void*)argument);
void set_selfthread_name(const char *name); void set_selfthread_name(const char *name);
void thread_enable_cancel(bool cancel);
/** A C++ wrapper for pthread threads. */ /** A C++ wrapper for pthread threads. */
class Thread { class Thread {

View File

@ -90,12 +90,6 @@ static void lms_log_callback(int lvl, const char *msg)
LOGLV(DLMS, lvl_map[lvl]) << 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) static void print_range(const char* name, lms_range_t *range)
{ {
LOGC(DDEV, INFO) << name << ": Min=" << range->min << " Max=" << range->max LOGC(DDEV, INFO) << name << ": Min=" << range->min << " Max=" << range->max

View File

@ -357,12 +357,6 @@ void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg)
} }
#endif #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, uhd_device::uhd_device(size_t tx_sps, size_t rx_sps,
InterfaceType iface, size_t chans, double lo_offset, InterfaceType iface, size_t chans, double lo_offset,
const std::vector<std::string>& tx_paths, const std::vector<std::string>& tx_paths,