Hi all,
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 try_recv
.
Does this sound like a reasonable approach? Other ideas include:
- Another obvious approach would be to make a single
channel
with anenum
type 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
chan
crate, but that requires every user of the sender crate to also use thechan
crate, 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 saidSender
trait, since otherwise every user of the library would need to define it... although I could at least define it formpsc::Sender
.
I'm sure there are other alternatives, but I'd love to hear what y'all would recommend as a workaround for select!
.