Upgrade to rustc 551a74dddd84cf01440ee84148ebd18bc68bd7c8.

This commit is contained in:
Simon Sapin 2015-04-23 00:14:02 +02:00 committed by Josh Matthews
parent 7b87085c18
commit ef8edd4e87
168 changed files with 2247 additions and 2408 deletions

View file

@ -0,0 +1,31 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// A quick hack to work around the removal of [`std::old_io::timer::Timer`](
/// http://doc.rust-lang.org/1.0.0-beta/std/old_io/timer/struct.Timer.html )
use std::sync::mpsc::{channel, Receiver};
use std::thread::{spawn, sleep_ms};
pub fn oneshot(duration_ms: u32) -> Receiver<()> {
let (tx, rx) = channel();
spawn(move || {
sleep_ms(duration_ms);
let _ = tx.send(());
});
rx
}
pub fn periodic(duration_ms: u32) -> Receiver<()> {
let (tx, rx) = channel();
spawn(move || {
loop {
sleep_ms(duration_ms);
if tx.send(()).is_err() {
break
}
}
});
rx
}