summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.se>2020-08-11 11:38:56 +0100
committerMartin Braun <martin@gnuradio.org>2020-08-14 04:19:58 -0700
commit048e5b1ec1261422e1856f982ba97b4c371b3eb0 (patch)
treebfea76c73b96c45ffbea3f7c8831b13de5adc38b
parent41d6265b8b049b78757770d65cee7b7e2bbbab9f (diff)
blocks/message_strobe: Use atomic for thread sync
-rw-r--r--gr-blocks/lib/message_strobe_impl.cc2
-rw-r--r--gr-blocks/lib/message_strobe_impl.h3
-rw-r--r--gr-blocks/lib/message_strobe_random_impl.h3
3 files changed, 4 insertions, 4 deletions
diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc
index 094bb4348c..eb1f442874 100644
--- a/gr-blocks/lib/message_strobe_impl.cc
+++ b/gr-blocks/lib/message_strobe_impl.cc
@@ -48,8 +48,6 @@ message_strobe_impl::~message_strobe_impl() {}
bool message_strobe_impl::start()
{
- // NOTE: d_finished should be something explicitly thread safe. But since
- // nothing breaks on concurrent access, I'll just leave it as bool.
d_finished = false;
d_thread = gr::thread::thread(std::bind(&message_strobe_impl::run, this));
diff --git a/gr-blocks/lib/message_strobe_impl.h b/gr-blocks/lib/message_strobe_impl.h
index 1cb75492ea..f378054813 100644
--- a/gr-blocks/lib/message_strobe_impl.h
+++ b/gr-blocks/lib/message_strobe_impl.h
@@ -12,6 +12,7 @@
#define INCLUDED_GR_MESSAGE_STROBE_IMPL_H
#include <gnuradio/blocks/message_strobe.h>
+#include <atomic>
namespace gr {
namespace blocks {
@@ -20,7 +21,7 @@ class BLOCKS_API message_strobe_impl : public message_strobe
{
private:
gr::thread::thread d_thread;
- bool d_finished;
+ std::atomic<bool> d_finished;
long d_period_ms;
pmt::pmt_t d_msg;
const pmt::pmt_t d_port;
diff --git a/gr-blocks/lib/message_strobe_random_impl.h b/gr-blocks/lib/message_strobe_random_impl.h
index 5346c0c8ac..400ed3a2ac 100644
--- a/gr-blocks/lib/message_strobe_random_impl.h
+++ b/gr-blocks/lib/message_strobe_random_impl.h
@@ -13,6 +13,7 @@
#include <gnuradio/blocks/message_strobe_random.h>
+#include <atomic>
#include <random>
namespace gr {
@@ -29,7 +30,7 @@ private:
std::normal_distribution<> nd; //(d_mean_ms, d_std_ms);
std::uniform_real_distribution<> ud; //(d_mean_ms - d_std_ms, d_mean_ms + d_std_ms);
gr::thread::thread d_thread;
- bool d_finished;
+ std::atomic<bool> d_finished;
pmt::pmt_t d_msg;
const pmt::pmt_t d_port;