Skip to content

spawn_listener2 #2471

@jesse99

Description

@jesse99

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;
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions