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

Skip to content

fix std::system_error in TimeoutNode #549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion include/behaviortree_cpp/decorators/timeout_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,15 @@ class TimeoutNode : public DecoratorNode
if (msec_ > 0)
{
timer_id_ = timer_.add(std::chrono::milliseconds(msec_), [this](bool aborted) {
// Return immediately if the timer was aborted.
// This function could be invoked during destruction of this object and
// we don't want to access member variables if not needed.
if (aborted)
{
return;
}
std::unique_lock<std::mutex> lk(timeout_mutex_);
if (!aborted && child()->status() == NodeStatus::RUNNING)
if (child()->status() == NodeStatus::RUNNING)
{
child_halted_ = true;
haltChild();
Expand Down
2 changes: 2 additions & 0 deletions include/behaviortree_cpp/decorators/timer_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ class TimerQueue

lk.unlock();
if (item.handler)
{
item.handler(item.id == 0);
}
lk.lock();
}
}
Expand Down