Skip to content

Commit a72d63a

Browse files
Document the MSVC timer resolution caveat of Tree::sleep (#1257)
Tree::sleep() waits on a std::condition_variable. On MSVC the wait_for() timeout is rounded up to the system timer resolution (about 15.6 ms, microsoft/STL#2173), so a 1 ms sleep can take ~16 ms and tickWhileRunning() cannot run much faster than 64 Hz on Windows. Add a note to the Tree::sleep() documentation, with the workaround from the STL issue thread (timeBeginPeriod(1)) that needs no library change. Fixes #1134 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e3e2fc4 commit a72d63a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎include/behaviortree_cpp/bt_factory.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ class Tree
133133
* @param timeout duration of the sleep
134134
* @return true if the timeout was NOT reached and the signal was received.
135135
*
136+
* @note On MSVC, std::condition_variable::wait_for() rounds the timeout up to the
137+
* system timer resolution (about 15.6 ms), see microsoft/STL#2173. A short sleep, e.g.
138+
* in tickWhileRunning(), can take much longer there. Calling timeBeginPeriod(1) once
139+
* at startup (Windows API, links winmm) restores a 1 ms resolution.
140+
*
136141
* */
137142
bool sleep(std::chrono::system_clock::duration timeout);
138143

0 commit comments

Comments
 (0)