Skip to content

Commit

Permalink
Expose return value of wait_for (BehaviorTree#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonynajjar authored Nov 25, 2024
1 parent 945a34d commit f5e98fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions include/behaviortree_cpp/bt_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ class Tree

[[nodiscard]] TreeNode* rootNode() const;

/// Sleep for a certain amount of time.
/// This sleep could be interrupted by the method
/// TreeNode::emitWakeUpSignal()
void sleep(std::chrono::system_clock::duration timeout);
/**
* @brief Sleep for a certain amount of time. This sleep could be interrupted by the method TreeNode::emitWakeUpSignal()
*
* @param timeout duration of the sleep
* @return true if the timeout was NOT reached and the signal was received.
*
* */
bool sleep(std::chrono::system_clock::duration timeout);

~Tree();

Expand Down
5 changes: 3 additions & 2 deletions src/bt_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,10 @@ TreeNode* Tree::rootNode() const
return subtree_nodes.empty() ? nullptr : subtree_nodes.front().get();
}

void Tree::sleep(std::chrono::system_clock::duration timeout)
bool Tree::sleep(std::chrono::system_clock::duration timeout)
{
wake_up_->waitFor(std::chrono::duration_cast<std::chrono::milliseconds>(timeout));
return wake_up_->waitFor(
std::chrono::duration_cast<std::chrono::milliseconds>(timeout));
}

Tree::~Tree()
Expand Down

0 comments on commit f5e98fd

Please sign in to comment.