Skip to content

Ilooping senders starve other tasks #8827

Closed
@brson

Description

@brson

Depending on number of threads and steal results this test case may livelock, and probably exhaust memory:

fn periodical(n: int) -> Port<bool> {
    let (port, chan) = stream();
    do spawn {
        println(fmt!("periodical %d - begin", n));
        loop {
            for _ in range(1, n) {
                println(fmt!("periodical %d - sending...", n));
                chan.send(false);
                println(fmt!("periodical %d - sent", n));
            }
            chan.send(true);
        }
    }
    return port;
}

fn integers() -> Port<int> {
    let (port, chan) = stream();
    do spawn {
        println("integers - begin");
        let mut i = 1;
        loop {
            chan.send(i);
            i = i + 1;
        }
    }
    return port;
}

fn main() {
    let ints = integers();
    let threes = periodical(3);
    let fives = periodical(5);
    for _ in range(1, 100) {
        match (ints.recv(), threes.recv(), fives.recv()) {
            (_, true, true) => println("FizzBuzz"),
            (_, true, false) => println("Fizz"),
            (_, false, true) => println("Buzz"),
            (i, false, false) => println(fmt!("%d", i))
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions