smol-rs / async-channel

Async multi-producer multi-consumer channel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sending can yield the thread

NathanRoyer opened this issue · comments

When we call try_send on a sender, here's what I think is happening:

  • ConcurrentQueue::push is called here
  • If the queue is unbounded, Unbounded::push is called here
  • If the queue reached its current capacity, busy_wait is called here
  • Which either spins or yields the thread, as defined here

I find it weird that we end up yielding the thread in async code.
If this is expected, I think it should be documented.