Skip to content

Conversation

@ecton
Copy link
Member

@ecton ecton commented Jan 13, 2025

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.

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.
@ecton ecton changed the title Initial Channel implementation Add a Channel-like type Jan 13, 2025
ecton added 4 commits January 20, 2025 09:52
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.
@ecton ecton marked this pull request as ready for review January 21, 2025 18:00
ecton added 5 commits January 22, 2025 09:29
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.
@ecton ecton merged commit f0823cc into main Jan 22, 2025
5 of 8 checks passed
@ecton ecton deleted the channel branch January 22, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants