2014-04-14 09:06:14 -05:00
|
|
|
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
// This test may not always fail, but it can be flaky if the race it used to
|
|
|
|
// expose is still present.
|
|
|
|
|
2014-12-23 13:53:35 -06:00
|
|
|
use std::sync::mpsc::{channel, Sender, Receiver};
|
2014-12-22 11:04:23 -06:00
|
|
|
use std::thread::Thread;
|
|
|
|
|
2014-04-14 09:06:14 -05:00
|
|
|
fn helper(rx: Receiver<Sender<()>>) {
|
|
|
|
for tx in rx.iter() {
|
2014-12-23 13:53:35 -06:00
|
|
|
let _ = tx.send(());
|
2014-04-14 09:06:14 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-30 23:09:29 -05:00
|
|
|
fn main() {
|
2014-04-14 09:06:14 -05:00
|
|
|
let (tx, rx) = channel();
|
2014-12-22 11:04:23 -06:00
|
|
|
let _t = Thread::spawn(move|| { helper(rx) }).detach();
|
2014-06-27 14:30:25 -05:00
|
|
|
let (snd, rcv) = channel::<int>();
|
2014-04-21 16:58:52 -05:00
|
|
|
for _ in range(1i, 100000i) {
|
2014-12-23 13:53:35 -06:00
|
|
|
snd.send(1i).unwrap();
|
2014-04-14 09:06:14 -05:00
|
|
|
let (tx2, rx2) = channel();
|
2014-12-23 13:53:35 -06:00
|
|
|
tx.send(tx2).unwrap();
|
2014-04-14 09:06:14 -05:00
|
|
|
select! {
|
2014-12-23 13:53:35 -06:00
|
|
|
_ = rx2.recv() => (),
|
2014-04-14 09:06:14 -05:00
|
|
|
_ = rcv.recv() => ()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|