I know there is the unstable
select!, but I want to use stable code. The best idea I have right now is to pass the thread to all senders, and have them run an unpark after sending, which if I use a buffered channel ought to enable the receiving thread to
park after checking if anything is ready with
Does this sound like a reasonable approach? Other ideas include:
- Another obvious approach would be to make a single
enumtype carrying the two kinds of information. I’d prefer to avoid that, since one of the two send channels is passed to a different crate (which shouldn’t know about the other channel).
- I could alternatively use the
chancrate, but that requires every user of the sender crate to also use the
chancrate, and I’d rather keep its API using the standard library.
- Another option would be to have its API accept a “sender” trait object (or a generic), which would enable me to write a sender that wraps the information in an
enum. That would enable maximum flexibility in the API, but it would be nicer if the standard library defined said
Sendertrait, since otherwise every user of the library would need to define it… although I could at least define it for
I’m sure there are other alternatives, but I’d love to hear what y’all would recommend as a workaround for