Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "rendez-vous" mode #27

Open
64kramsystem opened this issue Aug 28, 2020 · 1 comment
Open

Implement "rendez-vous" mode #27

64kramsystem opened this issue Aug 28, 2020 · 1 comment

Comments

@64kramsystem
Copy link

(This is related to #7, however, that treats a buffer size of 0 as inappropriate value, here it's to discuss its usefulness).

The stdlib mpsc module has a sync_channel(bound: usize)](https://doc.rust-lang.org/std/sync/mpsc/fn.sync_channel.html) method.

The case where bound == 0 is actually made explicit:

Note that a buffer size of 0 is valid, in which case this becomes "rendezvous channel" where each send will not return until a recv is paired with it.

I think that this should not be discarded as "not useful". The reason is that, with a buffer size of 0, this library can be used effectively (for example) to sync threads. By waiting for all receivers to read, a sender can ensure that all the receivers are in the expected state. mpsc can do that, but it's significantly slower.

@jonhoo
Copy link
Owner

jonhoo commented Aug 28, 2020

Using bound == 0 as a synchronizing channel makes a lot of sense, though unfortunately (as I referenced in that issue), making the implementation support this use-case is actually fairly tricky. Happy to take a look at a PR if you want to take a stab at implementing it though!

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

No branches or pull requests

2 participants