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

Ilooping senders starve other tasks #8827

Closed
brson opened this issue Aug 28, 2013 · 1 comment
Closed

Ilooping senders starve other tasks #8827

brson opened this issue Aug 28, 2013 · 1 comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@brson
Copy link
Contributor

brson commented Aug 28, 2013

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))
        }
    }
}
@alexcrichton
Copy link
Member

This appears to no longer be a problem. Even if all the prints are removed (which trigger task scheduling), this test completes.

Flagging as needstest.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Feb 3, 2014
bors added a commit that referenced this issue Apr 28, 2014
xFrednet pushed a commit to xFrednet/rust that referenced this issue May 21, 2022
Add `duplicate_mod` lint

Inspired by rust-lang#8827, warns if there's a single file that is loaded by more than one `mod` item

```rust,ignore
// lib.rs
mod a;
mod b;
```
```rust,ignore
// a.rs
#[path = "./b.rs"]
mod b;
```

It adds a `canonicalize` call per `mod file;` encountered, which I don't think should be too heavy

Integration tests with common modules, e.g. [`test_utils`](https://github.com/rust-lang/rust-clippy/tree/2038084cf2253b57cf8b405ab000a92b68346f43/tests/test_utils) doesn't trigger it as each test is compiled separately, however I couldn't figure out a good way to add a test for that

changelog: Add [`duplicate_mod`] lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants