Conversation
This new type isn't integrated in with any of the existing types yet. This is a step towards what is needed to implement the command pattern, which I think is the best approach for #192. I think we might need a Broadcast channel type as well to allow a channel type where multiple callbacks can be associated rather than a single, but it will require a Clone bound or extra allocations and the current implementation doesn't need either.
Also flushed out the APIs in general.
There aren't many places where Cushy outputs a signal and doesn't expect a response. Buttons and menus seem to be the only places where values are sent and not received. Many of the value based widgets often need to store and read the values, leading to channel integration not really being useful. So in the end, it seems like channel support in Cushy really is focused around solving certain data flow problems easier by leveraging a runtime provided by Cushy.
When multiple values were in queue, the callback would get executed for the first and then the future that called this method would only loop to poll the generated futures before returning Poll::Pending. This would leave the remaining values in queue. Now the callback is repeatedly called until the queue is emptied.
I originally thought the need to keep everything lock-step was too much of a burden, but I realized by removing the usage of mpsc, I could support a Receiver interface by using send_async in an on_receive_async callback. While this adds overhead if the receiver is then turned into a callback, that's not the intended workflow -- and it still works just fine, just has a little more overhead.
Also added missing for_each_subsequent variants.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This new type isn't integrated in with any of the existing types yet. This is a step towards what is needed to implement the command pattern, which I think is the best approach for #192.
I think we might need a Broadcast channel type as well to allow a channel type where multiple callbacks can be associated rather than a single, but it will require a Clone bound or extra allocations and the current implementation doesn't need either.