multiqueue
multiqueue copied to clipboard
MPMC queue deadlocks
The following code deadlocks on my machine. You might have to run several times to hit the bug.
extern crate crossbeam;
extern crate multiqueue;
fn main() {
const MESSAGES: usize = 1_000_000;
const THREADS: usize = 2;
let (tx, rx) = multiqueue::mpmc_queue(MESSAGES as u64);
crossbeam::scope(|s| {
for _ in 0..THREADS {
let tx = tx.clone();
s.spawn(move || {
for _ in 0..MESSAGES / THREADS {
while tx.try_send(()).is_err() {}
}
});
}
for _ in 0..THREADS {
let rx = rx.clone();
s.spawn(move || {
for _ in 0..MESSAGES / THREADS {
rx.recv().unwrap();
}
});
}
});
}
thanks, pulling this out of hibernation so will look at it. Fixing some bugs I never got around to and that may reveal the cause of this
hey - was wondering: did you ever make headway on this? just ran it with the current version and encountered a deadlock. I spent a few minutes trying to discern what was happening but couldn't make heads or tails of it. Even if it can't be fixed immediately, it'd be nice to know what part of the code triggered the condition, if known. Thanks!
There is at least one bug with the current implementation, I'm working out a whether this directly competes with my current job before I do any future work though
I believe this is occurring with Tokio: https://stackoverflow.com/questions/53711246/tokio-with-multiqueue-sometimes-hangs-sometimes-works