Skip to content

Commit

Permalink
fix issue #852: thread safety in Loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Sep 21, 2024
1 parent 37f8c73 commit 208eacf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/behaviortree_cpp/loggers/abstract_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class StatusChangeLogger
std::vector<TreeNode::StatusChangeSubscriber> subscribers_;
TimestampType type_;
BT::TimePoint first_timestamp_ = {};
std::mutex callback_mutex_;
};

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

auto subscribeCallback = [this](TimePoint timestamp, const TreeNode& node,
NodeStatus prev, NodeStatus status) {
std::unique_lock lk(callback_mutex_);
if(enabled_ && (status != NodeStatus::IDLE || show_transition_to_idle_))
{
if(type_ == TimestampType::absolute)
Expand Down

0 comments on commit 208eacf

Please sign in to comment.