event-listener icon indicating copy to clipboard operation
event-listener copied to clipboard

[Question] Integration with loom or shuttle?

Open rmcgibbo opened this issue 3 years ago • 3 comments

Hi,

This package has been a lifesaver. I really unable to implement https://github.com/rmcgibbo/async-priority-channel (which whos API is basically copied completely from smol-rs/async-channel) without out.

One question: would it be straightforward/possible for event-listener to provide a hook to use loom or shuttle. I'd like to be able to test my code which depends on event-listener using these techniques if possible. https://github.com/tokio-rs/loom/pull/220 seems to indicate that the latest release of loom now handles SeqCst which is probably necessary.

rmcgibbo avatar Oct 13 '21 15:10 rmcgibbo

I would accept a PR to support loom in a similar way as https://github.com/crossbeam-rs/crossbeam/pull/487.

taiki-e avatar Oct 13 '21 15:10 taiki-e

I looked into this a bit tonight. It seems like event-listener relies heavily on std::thread::park() and std::thread::unpark which are not implemented yet on loom::thread. This PR added loom::thread without park: https://github.com/tokio-rs/loom/pull/175. This question seems to indicate that yield_now might be a substitute for park, but I don't think that'll work for event-listener at all. https://github.com/tokio-rs/loom/issues/133

Without park, it seems like the loom version and the normal version of event-listener would have to be very different (replace park/unpark with an extra loom::sync::mutex and loom::sync::condvar?), which is not desirable.

rmcgibbo avatar Oct 15 '21 03:10 rmcgibbo

It seems https://github.com/tokio-rs/loom/issues/133 has been resolved.

taiki-e avatar Jul 17 '22 13:07 taiki-e