-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
Idea: channel_match! macro #35
Comments
Macros aren't usually my thing, but I'll give it a go tonight! |
It would be great if I just switched from crossbream-channel to flume and rewriting those Another reason against closures is that borrowing get's easier. If two That said, I have no idea how selection is even implemented and how crossbeam's select works. So this might be a lot of work. With macros I could help, however. |
@LukasKalbertodt I'm planning to work on this at some point. In the meantime, you can use an enum to get the same behaviour like this (note: I think that crossbeam does something similar to this, but generated automatically): enum Selection<A, B, C> {
A(A),
B(B),
C(C),
}
match Selector::new()
.recv(&my_recv, Selection::A)
.send(&my_send, Selection::B)
.recv(&my_recv2, Selection::C)
.wait()
{
Selection::A(a) => ...,
Selection::B(b) => ...,
Selection::C(c) => ...,
} It's recently come to our attention, via #44 , that there may be a race condition in the selector code that causes it to hang in some specific circumstances (it might also just be a malfunctioning test). I'm going to try to find the time to address this over the next week but it's something to be aware of. |
To add to the topic of this issue in general: I spent a few hours last week writing a macro for this. It's not finished yet, but I have had some success. |
I wonder how this interacts with #39 for select macros in loops. |
@Restioson I think the key is probably to reduce the cost of construction of |
There might be some generic magic I don't know about that could make this even simpler.
The text was updated successfully, but these errors were encountered: