Skip to content

Commit ced041b

Browse files
committed
allow multiple instances ofthe loggers
1 parent a574bea commit ced041b

File tree

4 files changed

+2
-24
lines changed

4 files changed

+2
-24
lines changed

include/behaviortree_cpp/loggers/bt_cout_logger.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ namespace BT
1313

1414
class StdCoutLogger : public StatusChangeLogger
1515
{
16-
static std::atomic<bool> ref_count;
17-
1816
public:
1917
StdCoutLogger(const BT::Tree& tree);
2018
~StdCoutLogger() override;

include/behaviortree_cpp/loggers/bt_minitrace_logger.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ namespace BT
88
{
99
class MinitraceLogger : public StatusChangeLogger
1010
{
11-
static std::atomic<bool> ref_count;
12-
1311
public:
1412
MinitraceLogger(const BT::Tree& tree, const char* filename_json);
1513

src/loggers/bt_cout_logger.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,11 @@
22

33
namespace BT
44
{
5-
std::atomic<bool> StdCoutLogger::ref_count(false);
65

76
StdCoutLogger::StdCoutLogger(const BT::Tree& tree) : StatusChangeLogger(tree.rootNode())
8-
{
9-
bool expected = false;
10-
if(!ref_count.compare_exchange_strong(expected, true))
11-
{
12-
throw LogicError("Only one instance of StdCoutLogger shall be created");
13-
}
14-
}
7+
{}
158
StdCoutLogger::~StdCoutLogger()
16-
{
17-
ref_count.store(false);
18-
}
9+
{}
1910

2011
void StdCoutLogger::callback(Duration timestamp, const TreeNode& node,
2112
NodeStatus prev_status, NodeStatus status)
@@ -35,7 +26,6 @@ void StdCoutLogger::callback(Duration timestamp, const TreeNode& node,
3526
void StdCoutLogger::flush()
3627
{
3728
std::cout << std::flush;
38-
ref_count = false;
3929
}
4030

4131
} // namespace BT

src/loggers/bt_minitrace_logger.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,10 @@
66

77
namespace BT
88
{
9-
std::atomic<bool> MinitraceLogger::ref_count(false);
109

1110
MinitraceLogger::MinitraceLogger(const Tree& tree, const char* filename_json)
1211
: StatusChangeLogger(tree.rootNode())
1312
{
14-
bool expected = false;
15-
if(!ref_count.compare_exchange_strong(expected, true))
16-
{
17-
throw LogicError("Only one instance of MinitraceLogger shall be created");
18-
}
19-
2013
mtr_register_sigint_handler();
2114
mtr_init(filename_json);
2215
this->enableTransitionToIdle(true);
@@ -26,7 +19,6 @@ MinitraceLogger::~MinitraceLogger()
2619
{
2720
mtr_flush();
2821
mtr_shutdown();
29-
ref_count = false;
3022
}
3123

3224
const char* toConstStr(NodeType type)

0 commit comments

Comments
 (0)