rust/src/libstd/task.rs

45 lines
1.4 KiB
Rust
Raw Normal View History

// Copyright 2012-2013 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.
//! Deprecated in favor of `thread`.
2012-11-18 19:56:50 -06:00
#![deprecated = "use std::thread instead"]
2014-12-06 20:34:37 -06:00
use any::Any;
use boxed::Box;
use thread;
use kinds::Send;
2014-12-06 20:34:37 -06:00
use result::Result;
use ops::FnOnce;
2012-11-18 19:56:50 -06:00
/// Deprecate: use `std::thread::Builder` instead.
#[deprecated = "use std::thread::Builder instead"]
pub type TaskBuilder = thread::Builder;
/// Deprecated: use `std::thread::Thread::spawn` and `detach` instead.
#[deprecated = "use std::thread::Thread::spawn and detach instead"]
pub fn spawn<F>(f: F) where F: FnOnce(), F: Send {
thread::Thread::spawn(f).detach();
}
2014-12-06 20:34:37 -06:00
/// Deprecated: use `std::thread::Thread::spawn` and `join` instead.
#[deprecated = "use std::thread::Thread::spawn and join instead"]
pub fn try<T, F>(f: F) -> Result<T, Box<Any + Send>> where
T: Send, F: FnOnce() -> T, F: Send
{
thread::Thread::spawn(f).join()
2014-12-06 20:34:37 -06:00
}
/// Deprecated: use `std::thread::Thread::yield_now instead`.
#[deprecated = "use std::thread::Thread::yield_now instead"]
pub fn deschedule() {
thread::Thread::yield_now()
}