move thread class into srslte namespace to avoid ambiguity between std::thread

master
Andre Puschmann 5 years ago
parent 8b46f631c1
commit a8bbe551ac

@ -34,7 +34,7 @@
#include <iostream>
#include <memory>
class netsource_handler : public thread
class netsource_handler : public srslte::thread
{
public:
netsource_handler(const std::string name_) : thread(name_) { rx_buf = unique_byte_array_t(new byte_array_t); }

@ -46,11 +46,16 @@ void threads_print_self();
#include <string>
namespace srslte {
;
class thread
{
public:
thread(const std::string& name_) : _thread(0), name(name_) {}
thread(const thread&) = delete;
thread(thread&& other) noexcept
{
_thread = other._thread;
@ -58,21 +63,30 @@ public:
other._thread = 0;
other.name = "";
}
thread& operator=(const thread&) = delete;
thread& operator=(thread&&) noexcept = delete;
bool start(int prio = -1) { return threads_new_rt_prio(&_thread, thread_function_entry, this, prio); }
bool start_cpu(int prio, int cpu) { return threads_new_rt_cpu(&_thread, thread_function_entry, this, cpu, prio); }
bool start_cpu_mask(int prio, int mask)
{
return threads_new_rt_mask(&_thread, thread_function_entry, this, mask, prio);
}
void print_priority() { threads_print_self(); }
void set_name(const std::string& name_)
{
name = name_;
pthread_setname_np(pthread_self(), name.c_str());
}
void wait_thread_finish() { pthread_join(_thread, NULL); }
void thread_cancel() { pthread_cancel(_thread); }
static std::string get_name()
@ -96,6 +110,7 @@ private:
((thread*)_this)->run_thread();
return NULL;
}
pthread_t _thread;
std::string name;
};
@ -104,12 +119,14 @@ class periodic_thread : public thread
{
public:
periodic_thread(const std::string name_) : thread(name_) {}
void start_periodic(int period_us_, int priority = -1)
{
run_enable = true;
period_us = period_us_;
start(priority);
}
void stop_thread()
{
run_enable = false;
@ -124,6 +141,7 @@ private:
int timer_fd;
int period_us;
bool run_enable;
void run_thread()
{
if (make_periodic()) {
@ -136,6 +154,7 @@ private:
}
}
}
int make_periodic()
{
int ret = -1;
@ -164,6 +183,7 @@ private:
}
return ret;
}
void wait_period()
{
unsigned long long missed;
@ -184,6 +204,8 @@ private:
}
};
} // namespace srslte
#endif // __cplusplus
#endif // SRSLTE_THREADS_H

@ -22,7 +22,7 @@
#include <iostream>
#include <srslte/common/threads.h>
class thread_test : public thread
class thread_test : public srslte::thread
{
public:
thread_test() : thread("Thread Test") {}

@ -30,7 +30,7 @@
namespace srsenb {
class prach_worker : thread
class prach_worker : srslte::thread
{
public:
prach_worker(uint32_t cc_idx_) : buffer_pool(8), thread("PRACH_WORKER") { cc_idx = cc_idx_; }

@ -34,7 +34,7 @@ namespace srsenb {
typedef _Complex float cf_t;
class txrx : public thread
class txrx : public srslte::thread
{
public:
txrx();

@ -48,7 +48,7 @@ class enb_stack_lte final : public enb_stack_base,
public stack_interface_s1ap_lte,
public stack_interface_gtpu_lte,
public stack_interface_mac_lte,
public thread
public srslte::thread
{
public:
enb_stack_lte(srslte::logger* logger_);

@ -59,7 +59,7 @@ struct pseudo_hdr {
uint16_t udp_len;
};
class mbms_gw : public thread
class mbms_gw : public srslte::thread
{
public:
static mbms_gw* get_instance(void);

@ -50,7 +50,7 @@ typedef struct {
enum nas_timer_type type;
} mme_timer_t;
class mme : public thread, public mme_interface_nas
class mme : public srslte::thread, public mme_interface_nas
{
public:
static mme* get_instance(void);

@ -62,7 +62,7 @@ typedef struct spgw_tunnel_ctx {
std::queue<srslte::byte_buffer_t*> paging_queue;
} spgw_tunnel_ctx_t;
class spgw : public thread
class spgw : public srslte::thread
{
class gtpc;
class gtpu;

@ -40,7 +40,7 @@ namespace srsue {
typedef _Complex float cf_t;
class phy : public ue_lte_phy_base, public thread
class phy : public ue_lte_phy_base, public srslte::thread
{
public:
explicit phy(srslte::logger* logger_) : logger(logger_), workers_pool(MAX_WORKERS), common(), thread("PHY"){};

@ -34,7 +34,7 @@ namespace scell {
#define SF_BUFFER_MAX_SAMPLES (5 * SRSLTE_SF_LEN_MAX)
class async_scell_recv : private thread
class async_scell_recv : private srslte::thread
{
public:
async_scell_recv();

@ -32,7 +32,7 @@ namespace srsue {
namespace scell {
// Class to perform intra-frequency measurements
class intra_measure : public thread
class intra_measure : public srslte::thread
{
/*
* The intra-cell measurment has 5 different states:

@ -45,7 +45,7 @@ namespace srsue {
typedef _Complex float cf_t;
class sync : public thread, public chest_feedback_itf
class sync : public srslte::thread, public chest_feedback_itf
{
public:
sync() : thread("SYNC"){};

@ -56,7 +56,7 @@ class ue_stack_lte final : public ue_stack_base,
public stack_interface_mac,
public stack_interface_rrc,
public task_handler_interface_lte,
public thread
public srslte::thread
{
public:
ue_stack_lte();

@ -46,7 +46,7 @@ struct gw_args_t {
std::string tun_dev_netmask;
};
class gw : public gw_interface_stack, public thread
class gw : public gw_interface_stack, public srslte::thread
{
public:
gw();

@ -58,7 +58,7 @@ private:
received_##NAME = true; \
}
class phy_test_bench : public thread
class phy_test_bench : public srslte::thread
{
private:
// Dummy classes

Loading…
Cancel
Save