Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01ab2b7

Browse files
committed
1 parent a33b312 commit 01ab2b7

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/loggers/bt_minitrace_logger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ MinitraceLogger::~MinitraceLogger()
2424
{
2525
minitrace::mtr_flush();
2626
minitrace::mtr_shutdown();
27-
ref_count = false;
27+
ref_count = false;
2828
}
2929

3030
void MinitraceLogger::callback(Duration /*timestamp*/,

src/loggers/bt_zmq_publisher.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,8 @@ PublisherZMQ::PublisherZMQ(const BT::Tree& tree, int max_msg_per_second)
2828
, send_pending_(false)
2929
, zmq_(new Pimpl())
3030
{
31-
static bool first_instance = true;
32-
if (first_instance)
33-
{
34-
first_instance = false;
35-
}
36-
else
31+
bool expected = false;
32+
if (!ref_count.compare_exchange_strong(expected, true))
3733
{
3834
throw LogicError("Only one instance of PublisherZMQ shall be created");
3935
}
@@ -86,7 +82,7 @@ PublisherZMQ::~PublisherZMQ()
8682
}
8783
flush();
8884
delete zmq_;
89-
ref_count = false;
85+
ref_count = false;
9086
}
9187

9288

0 commit comments

Comments
 (0)