Skip to content

Commit 208eacf

Browse files
committed
fix issue #852: thread safety in Loggers
1 parent 37f8c73 commit 208eacf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/behaviortree_cpp/loggers/abstract_logger.h

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class StatusChangeLogger
6161
std::vector<TreeNode::StatusChangeSubscriber> subscribers_;
6262
TimestampType type_;
6363
BT::TimePoint first_timestamp_ = {};
64+
std::mutex callback_mutex_;
6465
};
6566

6667
//--------------------------------------------
@@ -72,6 +73,7 @@ inline StatusChangeLogger::StatusChangeLogger(TreeNode* root_node)
7273

7374
auto subscribeCallback = [this](TimePoint timestamp, const TreeNode& node,
7475
NodeStatus prev, NodeStatus status) {
76+
std::unique_lock lk(callback_mutex_);
7577
if(enabled_ && (status != NodeStatus::IDLE || show_transition_to_idle_))
7678
{
7779
if(type_ == TimestampType::absolute)

0 commit comments

Comments
 (0)