threads: fix race in stopping periodic thread

This commit is contained in:
Andre Puschmann 2021-05-27 21:15:20 +02:00
parent 312b5a241c
commit 1ef3cb7e5d
1 changed files with 5 additions and 4 deletions

View File

@ -35,6 +35,7 @@ void threads_print_self();
#ifdef __cplusplus
}
#include <atomic>
#include <string>
namespace srsran {
@ -129,10 +130,10 @@ protected:
virtual void run_period() = 0;
private:
int wakeups_missed;
int timer_fd;
int period_us;
bool run_enable;
int wakeups_missed = 0;
int timer_fd = 0;
int period_us = 0;
std::atomic<bool> run_enable = {false};
void run_thread()
{