smol-rs / async-broadcast

Async broadcast channels
Apache License 2.0
163 stars 26 forks source link

Capacity change + overflow mode #1

Closed zeenix closed 3 years ago

zeenix commented 3 years ago

This PR adds:

zeenix commented 3 years ago

Converting it into a draft as this is broken for awaiting receivers. I'm working on it..

zeenix commented 3 years ago

Gah, the calculations/algorithm required here turned out to be quite a pickle. I have pushed my WIP work here and with the last commit the existing and the newly added test succeed now but testing it against zbus, reveals it's still broken as messages just get lost. So I could really use some help here or at least a second pair of eyes.

@yoshuawuyts @elmarco @tv42 ^

zeenix commented 3 years ago

The WIP work I just pushed seems to work fine. There is still at least one issue (if latest messages are dropped on capacity change, receivers are wrongly adjusted) and need to optimize the code a bit but hopefully the hard part is done and I can fix this today.

zeenix commented 3 years ago

I think I got it working, based on all the testing I can give it. If anyone else can have a look and tell me if this can be improved, please do let me know.

zeenix commented 3 years ago

All my testing has been green so far, so I'm merging this already. We can always fix things later if needed.