Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The pubsub library updates to clean up potential runtime errors. Every so often we can end up with a nil message. Which either means we dropped a message or we're attempting to process a message that isn't there. This can lead to issues in people attempting to use the library. Removing the complexity of knowing when to request the next message. It removes the ambiguity of knowing if you have a next message or not. The trick of knowing when next is blocking or not is also gone, as we can use the existing data channel. If that's already full (it's a buffered channel of 1), then just offer a default case in the select to allow the bypassing of the blocking operation. Message pointers in the implementation is gone, you either have a message or you don't. We no longer need to check for empty. And in doing so, the implementation iterates all the pending handlers at once, without checking for data or next each iteration. The interface is exactly the same, just the underlying queue implementation.
- Loading branch information