`TaskSchedule`: give error on `sleep*()` if last handle is dropped
This fixes an busy-loop.
When the last TaskHandle
on a TaskSchedule
is dropped, the
schedule is permanently canceled: whatever operation it was
scheduling should no longer be performed. But our code was broken:
the sleep()
and sleep_until_wallclock()
functions don't verify
whether the handles are dropped or not.
This breakage caused an CPU-eating busy-loop in
sleep_until_wallclock
.
With this patch, we now return a Result<(), SleepError>
from these
functions.
Fixes #572 (closed).