-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Description
Took me all day but I finally got a simple test case. If you cargo run this a few times it will eventually hang (on my machine anyway).
extern crate bus;
use std::thread;
use bus::Bus;
fn main() {
println!("Starting");
let strings = vec!["hi", "bye", "one", "two"];
let mut bus = Bus::new(2);
{
let recv = bus.add_rx();
thread::spawn(move || {
println!("Looping 1");
for rec in recv {
println!("Got 1 :: {}", rec);
}
});
};
{
let recv = bus.add_rx();
thread::spawn(move || {
println!("Looping 2");
for rec in recv {
println!("Got a 2 :: {}", rec);
}
});
};
for f in strings {
println!("bcast :: {}", f);
bus.broadcast(0);
}
println!("Done");
}
Example output
Finishes:
Finished dev [unoptimized + debuginfo] target(s) in 0.08s
Running `target/debug/fse_dump`
Starting
Looping 1
bcast :: hi
bcast :: bye
Looping 2
Got 1 :: 0
bcast :: one
Got 1 :: 0
Got 1 :: 0
Got a 2 :: 0
Got a 2 :: 0
Got a 2 :: 0
bcast :: two
Got 1 :: 0
Got a 2 :: 0
Done
Stuck:
Finished dev [unoptimized + debuginfo] target(s) in 0.06s
Running `target/debug/fse_dump`
Starting
Looping 1
bcast :: hi
Looping 2
Got a 2 :: 0
bcast :: bye
bcast :: one
Got 1 :: 0
Got 1 :: 0
Got 1 :: 0
bcast :: two
Machine info:
$ uname -a
Darwin 34363bc7dc9c 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,3 Darwin
$ rustc --version
rustc 1.33.0 (2aa4c46cf 2019-02-28)
Metadata
Metadata
Assignees
Labels
No labels