Skip to content

Commit f5e98fd

Browse files
authored
Expose return value of wait_for (BehaviorTree#887)
1 parent 945a34d commit f5e98fd

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

include/behaviortree_cpp/bt_factory.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,14 @@ class Tree
118118

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

121-
/// Sleep for a certain amount of time.
122-
/// This sleep could be interrupted by the method
123-
/// TreeNode::emitWakeUpSignal()
124-
void sleep(std::chrono::system_clock::duration timeout);
121+
/**
122+
* @brief Sleep for a certain amount of time. This sleep could be interrupted by the method TreeNode::emitWakeUpSignal()
123+
*
124+
* @param timeout duration of the sleep
125+
* @return true if the timeout was NOT reached and the signal was received.
126+
*
127+
* */
128+
bool sleep(std::chrono::system_clock::duration timeout);
125129

126130
~Tree();
127131

src/bt_factory.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,10 @@ TreeNode* Tree::rootNode() const
586586
return subtree_nodes.empty() ? nullptr : subtree_nodes.front().get();
587587
}
588588

589-
void Tree::sleep(std::chrono::system_clock::duration timeout)
589+
bool Tree::sleep(std::chrono::system_clock::duration timeout)
590590
{
591-
wake_up_->waitFor(std::chrono::duration_cast<std::chrono::milliseconds>(timeout));
591+
return wake_up_->waitFor(
592+
std::chrono::duration_cast<std::chrono::milliseconds>(timeout));
592593
}
593594

594595
Tree::~Tree()

0 commit comments

Comments
 (0)