Looking for something almost like crossbeam::channel

These shouldn't be too hard to implement with two pre-allocated buffers of type T and use of the RCU pattern:

  • has two states: FULL and EMPTY.
  • sender can send type T to receiver
  • send blocks while state is FULL
  • recv blocks while state is EMPTY
  • receiver can peek(). blocking or failing is fine. returns &T without setting state to EMPTY
  • It needs to be fast (no spin-wait!).
  • does not require T to have Clone
  • Does not need SPSC (precisely two threads interact with it)
  • Does not need more than 1 slot.

This may be a little tricky:

  • Bonus: send() and recv() return error as soon as their counterpart is dropped.

And this depends entirely on how select is implemented, and may be a performance challenge:

  • Need a way to select from a set of senders receivers (block until one becomes ready AND know which it was)
/r/rust Thread