futures-native-timers
futures-native-timers copied to clipboard
timers should be `Send`
test and make sure of this.
Hi, I was looking at the Linux implementation and I was wondering why it was explicitly made not Send. After further investigation it seems that according to the SIGNAL-SAFETY(7), it is not safe to call nonreentrant functions in signal handler. This would Mutex::lock(), I believe. I don't know, if this would cause problems with the other timer backends, but have you thought about replacing the Mutex solution with AtomicWaker (and possibly AtomicBool for done):
#[derive(Debug)]
pub (crate) struct TimerState {
wake: AtomicWaker,
done: AtomicBool,
}
and then simply Arc<TimerState> instead of Arc<Mutex<TimerState>>
Bumped into this problem. The most important part is that the Windows impl is Send, but Linux isn't, so on my dev machine it was working but when I tried to compile it on Linux suddenly it doesn't.
Yea it seems like the right solution is to use AtomicWaker, which is what other event sources (like tokio and romio) all do.