-
|
Code: Output:
The sem.timed_wait function does not wait for 50 seconds, and it returns false indicating that it is timeout. Am I using it wrongly? I was following the practice in src/internal_modules/roc_core/timer.cpp Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
You've found a bug, thanks! You're on linux, right?
However in Hence it returns immediately - monotonic timestamps are typically smaller than wallclock timestamps, and it thinks that deadline is already expired. I've created an issue: #795 You can fix it by yourself (it should be straightforward I guess), otherwise you could wait until I take a look, I think I'll have time next week. (Please let me know if you're waiting for a fix.) |
Beta Was this translation helpful? Give feedback.
You've found a bug, thanks! You're on linux, right?
deadlineparameter ofSemaphore::timed_waitis supposed to be absolute time inCLOCK_MONOTONICdomain. The code that uses it, as well as your example, pass monotonic timestamps to it.However in
roc_core/target_posix_ext/roc_core/semaphore.cppwe passdeadlinetosem_timedwait, which expects time inCLOCK_REALTIMEdomain (i.e. since epoch).Hence it returns immediately - monotonic timestamps are typically smaller than wallclock timestamps, and it thinks that deadline is already expired.
I've created an issue: #795
You can fix it by yourself (it should be straightforward I guess), otherwise you could wait until I take a look, I think I'll…