The problem is the implementation of std::this_thread:sleep_until(..) , which calls sleep_for(..) , which calls nanosleep() .
(See gnu sources , line 271.)
Pay attention to the following questions in Stackoverflow:
You do not need high resolution nanosleep() . You can write your own open source permissions solution and call sleep() instead of nanosleep().
If you need a sub-second resolution, I recommend the method to call select() rather than nanosleep() . select() designed for very effective blocking for subsecond delays, and the timeout parameter is fairly accurately observed by most operating systems, which is useful for subsecond synchronization, while simultaneously receiving a processor.
You can even create a socket to pass to select() in the error_fds parameter, where the socket can be used as a cross-thread signal when it is passed to close() , and the error state socket becomes.
source share