Skip to content

Expose return value of wait_for #887

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 3 commits into from
Nov 25, 2024
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
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
Loading