Add disconnected flavor which immediately fails#1047
Add disconnected flavor which immediately fails#1047ryoqun wants to merge 1 commit intocrossbeam-rs:masterfrom
Conversation
| } | ||
| } | ||
|
|
||
| /// Creates a receiver that is disconnected always. |
There was a problem hiding this comment.
I'm happy to expand this doccomment with an example, which will be based on the one in the pr description with polishes, once it's confirmed that this pr has some hope to be merged.
| } | ||
|
|
||
| impl<T> Channel<T> { | ||
| /// Creates a channel that always delivers messages. |
There was a problem hiding this comment.
oops forgot to update..
|
Thanks for the PR. I guess this could be replaced by never + disconnect once the API for explicit disconnection is exposed? |
hey, really thanks for replying! yeah, assuming the disconnected never is implemented in a hard-coded way without any state much like the never itself for maximum optimization opportunity by rustc. note that the tick approach in the pr description or just |
|
i think disconnected dummy sender might also be useful. ref: #750 how about this api? |
Yet another small niceties, i'd like to add to
crossbeam_channel.This doesn't look meaningful by itself at first glance. However, this is useful for conditionally inserting an artificial select arm at predetermined priority in the
select_biased!()#1040, combined withnever()like this:Note that using
tick()like below introduces needless calls toInstant::now()(which is a vdso basically) per select invocation on top of the needless stack memory consumption. (On the other hand, the zst &const-code-heavydisconnected()will be optimized out to great degree after the macro expansion)..:Also, unrolling the select is possible, but creates code duplication. Lastly, checking
is_local_task_availableafterselect_biased!()alone would introduce a priority inversion.Thus, i think there's no acceptable alternative solution currently.