Gabriella439 / pipes-concurrency

Concurrency for the pipes ecosystem
BSD 3-Clause "New" or "Revised" License
43 stars 12 forks source link

Bounded Buffer and TBQueue #23

Closed PierreR closed 10 years ago

PierreR commented 10 years ago

My understanding of the Bounded Buffer is that writes block when the queue is full.

As a first note, I believe the documentation within the code could be more explicit (I can submit a pull request)

For Bounded Buffer, how do we handle the case where all inputs have died ? Or when inputs might start losing ground badly but should manage to recover dynamically ? This is a case where we might be willing to lose messages temporally instead of blocking: a tradeoff between Bounded and Latest.

Just some thoughts really. I don't have a precise use case for this.

Gabriella439 commented 10 years ago

I'll welcome any pull request to improve the documentation.

So I don't have an existing solution for dynamic recovery, but there is a new abstraction called New which is like Latest except that reads will block if there's no new messages. However, New discards all old messages and doesn't save anything.

Maybe we could generalize new by defining a buffer that is like Bounded except that if it overflows it discards values. Let's pretend for a moment that we call this buffer Save n, where n is the number of messages it will save before discarding old messages (in the order it received them). Then New would just be the special case where n = 1.

Gabriella439 commented 10 years ago

The more I think about this the more I like it, but I think I will rename Save to Newest instead.