capnproto icon indicating copy to clipboard operation
capnproto copied to clipboard

Why does WaiterQueue::fulfill require the queue to be empty?

Open fabiorossetto opened this issue 1 year ago • 4 comments

I'd like to make two changes to the WaiterQueue class, but I'd like some feedback first.

  1. WaiterQueue::fulfill and WaiterQueue::reject require the queue to be non-empty. I'm not sure I understand the meaning of this. To me it seems pretty natural that if you call fulfill, and nobody is waiting for that value, the value is simply discarded. How can the producer ensure that there are consumers ready before pushing a value?
  2. If WaiterQueue is destroyed and there are outstanding waiters, those waiters will be left hanging. AFAIK this is different from the behavior of Promise/Fulfiller pairs. If a Fulfiller is destroyed and its Promise still exists, the Promise should be rejected.

fabiorossetto avatar Mar 23 '23 16:03 fabiorossetto