You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seeing how there is a comm::select2 I think that it would be useful to have a spawn_listener2. Fwiw the use case I have in mind is a task that allows other tasks to get copies of and mutate state shared by the tasks:
fn manage_state(get_state_port: comm::port<comm::chan<str>>, set_state_port: comm::port<str>)
{
let mut state = "default";
loop
{
alt comm::select2(get_state_port, set_state_port)
{
either::left(channel)
{
comm::send(channel, copy(state));
}
either::right(new_state)
{
state = new_state;
}
}
}
}
I was trying to leverage the type system so that reader tasks could only read state and writer tasks could only write state. It's probably not that big of a deal though and the code is simpler with an enum like the above.
Activity
nikomatsakis commentedon May 31, 2012
why would you use two ports in place of a port with an enum message like:
?
jesse99 commentedon Jun 1, 2012
I was trying to leverage the type system so that reader tasks could only read state and writer tasks could only write state. It's probably not that big of a deal though and the code is simpler with an enum like the above.
catamorphism commentedon Jun 7, 2012
Closing since it sounds like there's a good workaround for this.
Auto merge of rust-lang#2471 - RalfJung:term, r=RalfJung
Add jq to deps (rust-lang#2471)
Merge pull request rust-lang#2471 from Darksonn/patch-1
Merge rust-lang#2471