Calling sleep_for with nanoseconds (or less) durations would be cast to 0us or 0ms. This is now fixed by making the duration at least 1us or 1ms. (cc @TomSaw)
The condition was not checked again after a yield, thus can time out if the yield takes longer. The correct behavior should check the function upon entry of the poll for a fast exit and then again after each yield before checking the timeout.
Fix infinite loop when passing 0s as sleep time, whoops. Now it only yields once.
There are two problems with the poll functions:
sleep_for
with nanoseconds (or less) durations would be cast to 0us or 0ms. This is now fixed by making the duration at least 1us or 1ms. (cc @TomSaw)