auto merge of #14900 : alexcrichton/rust/snapshots, r=huonw

Closes #14898
Closes #14918
This commit is contained in:
bors 2014-06-16 08:16:49 +00:00
commit 7ec78053ec
94 changed files with 321 additions and 841 deletions

View file

@ -91,7 +91,7 @@ impl<T: 'static> LocalData for T {}
// a proper map.
#[doc(hidden)]
pub type Map = Vec<Option<(*u8, TLSValue, uint)>>;
type TLSValue = Box<LocalData:Send>;
type TLSValue = Box<LocalData + Send>;
// Gets the map from the runtime. Lazily initialises if not done so already.
unsafe fn get_local_map() -> Option<&mut Map> {
@ -175,7 +175,7 @@ impl<T: 'static> KeyValue<T> {
// anything.
let newval = data.map(|d| {
let d = box d as Box<LocalData>;
let d: Box<LocalData:Send> = unsafe { mem::transmute(d) };
let d: Box<LocalData + Send> = unsafe { mem::transmute(d) };
(keyval, d, 0)
});
@ -236,7 +236,7 @@ impl<T: 'static> KeyValue<T> {
// pointer part of the trait, (as ~T), and then use
// compiler coercions to achieve a '&' pointer.
let ptr = unsafe {
let data = data as *Box<LocalData:Send> as *raw::TraitObject;
let data = data as *Box<LocalData + Send> as *raw::TraitObject;
&mut *((*data).data as *mut T)
};
Ref { _ptr: ptr, _index: pos, _nosend: marker::NoSend, _key: self }

View file

@ -25,11 +25,11 @@ use task::Task;
pub trait EventLoop {
fn run(&mut self);
fn callback(&mut self, arg: proc():Send);
fn pausable_idle_callback(&mut self, Box<Callback:Send>)
-> Box<PausableIdleCallback:Send>;
fn remote_callback(&mut self, Box<Callback:Send>)
-> Box<RemoteCallback:Send>;
fn callback(&mut self, arg: proc(): Send);
fn pausable_idle_callback(&mut self, Box<Callback + Send>)
-> Box<PausableIdleCallback + Send>;
fn remote_callback(&mut self, Box<Callback + Send>)
-> Box<RemoteCallback + Send>;
/// The asynchronous I/O services. Not all event loops may provide one.
fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory>;
@ -189,24 +189,24 @@ impl<'a> LocalIo<'a> {
pub trait IoFactory {
// networking
fn tcp_connect(&mut self, addr: SocketAddr,
timeout: Option<u64>) -> IoResult<Box<RtioTcpStream:Send>>;
timeout: Option<u64>) -> IoResult<Box<RtioTcpStream + Send>>;
fn tcp_bind(&mut self, addr: SocketAddr)
-> IoResult<Box<RtioTcpListener:Send>>;
-> IoResult<Box<RtioTcpListener + Send>>;
fn udp_bind(&mut self, addr: SocketAddr)
-> IoResult<Box<RtioUdpSocket:Send>>;
-> IoResult<Box<RtioUdpSocket + Send>>;
fn unix_bind(&mut self, path: &CString)
-> IoResult<Box<RtioUnixListener:Send>>;
-> IoResult<Box<RtioUnixListener + Send>>;
fn unix_connect(&mut self, path: &CString,
timeout: Option<u64>) -> IoResult<Box<RtioPipe:Send>>;
timeout: Option<u64>) -> IoResult<Box<RtioPipe + Send>>;
fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>,
hint: Option<AddrinfoHint>)
-> IoResult<Vec<AddrinfoInfo>>;
// filesystem operations
fn fs_from_raw_fd(&mut self, fd: c_int, close: CloseBehavior)
-> Box<RtioFileStream:Send>;
-> Box<RtioFileStream + Send>;
fn fs_open(&mut self, path: &CString, fm: FileMode, fa: FileAccess)
-> IoResult<Box<RtioFileStream:Send>>;
-> IoResult<Box<RtioFileStream + Send>>;
fn fs_unlink(&mut self, path: &CString) -> IoResult<()>;
fn fs_stat(&mut self, path: &CString) -> IoResult<FileStat>;
fn fs_mkdir(&mut self, path: &CString, mode: uint) -> IoResult<()>;
@ -225,24 +225,24 @@ pub trait IoFactory {
IoResult<()>;
// misc
fn timer_init(&mut self) -> IoResult<Box<RtioTimer:Send>>;
fn timer_init(&mut self) -> IoResult<Box<RtioTimer + Send>>;
fn spawn(&mut self, cfg: ProcessConfig)
-> IoResult<(Box<RtioProcess:Send>,
Vec<Option<Box<RtioPipe:Send>>>)>;
-> IoResult<(Box<RtioProcess + Send>,
Vec<Option<Box<RtioPipe + Send>>>)>;
fn kill(&mut self, pid: libc::pid_t, signal: int) -> IoResult<()>;
fn pipe_open(&mut self, fd: c_int) -> IoResult<Box<RtioPipe:Send>>;
fn pipe_open(&mut self, fd: c_int) -> IoResult<Box<RtioPipe + Send>>;
fn tty_open(&mut self, fd: c_int, readable: bool)
-> IoResult<Box<RtioTTY:Send>>;
fn signal(&mut self, signal: int, cb: Box<Callback:Send>)
-> IoResult<Box<RtioSignal:Send>>;
-> IoResult<Box<RtioTTY + Send>>;
fn signal(&mut self, signal: int, cb: Box<Callback + Send>)
-> IoResult<Box<RtioSignal + Send>>;
}
pub trait RtioTcpListener : RtioSocket {
fn listen(~self) -> IoResult<Box<RtioTcpAcceptor:Send>>;
fn listen(~self) -> IoResult<Box<RtioTcpAcceptor + Send>>;
}
pub trait RtioTcpAcceptor : RtioSocket {
fn accept(&mut self) -> IoResult<Box<RtioTcpStream:Send>>;
fn accept(&mut self) -> IoResult<Box<RtioTcpStream + Send>>;
fn accept_simultaneously(&mut self) -> IoResult<()>;
fn dont_accept_simultaneously(&mut self) -> IoResult<()>;
fn set_timeout(&mut self, timeout: Option<u64>);
@ -256,7 +256,7 @@ pub trait RtioTcpStream : RtioSocket {
fn nodelay(&mut self) -> IoResult<()>;
fn keepalive(&mut self, delay_in_seconds: uint) -> IoResult<()>;
fn letdie(&mut self) -> IoResult<()>;
fn clone(&self) -> Box<RtioTcpStream:Send>;
fn clone(&self) -> Box<RtioTcpStream + Send>;
fn close_write(&mut self) -> IoResult<()>;
fn close_read(&mut self) -> IoResult<()>;
fn set_timeout(&mut self, timeout_ms: Option<u64>);
@ -284,7 +284,7 @@ pub trait RtioUdpSocket : RtioSocket {
fn hear_broadcasts(&mut self) -> IoResult<()>;
fn ignore_broadcasts(&mut self) -> IoResult<()>;
fn clone(&self) -> Box<RtioUdpSocket:Send>;
fn clone(&self) -> Box<RtioUdpSocket + Send>;
fn set_timeout(&mut self, timeout_ms: Option<u64>);
fn set_read_timeout(&mut self, timeout_ms: Option<u64>);
fn set_write_timeout(&mut self, timeout_ms: Option<u64>);
@ -292,8 +292,8 @@ pub trait RtioUdpSocket : RtioSocket {
pub trait RtioTimer {
fn sleep(&mut self, msecs: u64);
fn oneshot(&mut self, msecs: u64, cb: Box<Callback:Send>);
fn period(&mut self, msecs: u64, cb: Box<Callback:Send>);
fn oneshot(&mut self, msecs: u64, cb: Box<Callback + Send>);
fn period(&mut self, msecs: u64, cb: Box<Callback + Send>);
}
pub trait RtioFileStream {
@ -319,7 +319,7 @@ pub trait RtioProcess {
pub trait RtioPipe {
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint>;
fn write(&mut self, buf: &[u8]) -> IoResult<()>;
fn clone(&self) -> Box<RtioPipe:Send>;
fn clone(&self) -> Box<RtioPipe + Send>;
fn close_write(&mut self) -> IoResult<()>;
fn close_read(&mut self) -> IoResult<()>;
@ -329,11 +329,11 @@ pub trait RtioPipe {
}
pub trait RtioUnixListener {
fn listen(~self) -> IoResult<Box<RtioUnixAcceptor:Send>>;
fn listen(~self) -> IoResult<Box<RtioUnixAcceptor + Send>>;
}
pub trait RtioUnixAcceptor {
fn accept(&mut self) -> IoResult<Box<RtioPipe:Send>>;
fn accept(&mut self) -> IoResult<Box<RtioPipe + Send>>;
fn set_timeout(&mut self, timeout: Option<u64>);
}

View file

@ -46,12 +46,12 @@ pub struct Task {
pub destroyed: bool,
pub name: Option<SendStr>,
imp: Option<Box<Runtime:Send>>,
imp: Option<Box<Runtime + Send>>,
}
pub struct TaskOpts {
/// Invoke this procedure with the result of the task when it finishes.
pub on_exit: Option<proc(Result):Send>,
pub on_exit: Option<proc(Result): Send>,
/// A name for the task-to-be, for identification in failure messages
pub name: Option<SendStr>,
/// The size of the stack for the spawned task
@ -64,7 +64,7 @@ pub struct TaskOpts {
///
/// If you wish for this result's delivery to block until all
/// children tasks complete, recommend using a result future.
pub type Result = ::core::result::Result<(), Box<Any:Send>>;
pub type Result = ::core::result::Result<(), Box<Any + Send>>;
pub struct GarbageCollector;
pub struct LocalStorage(pub Option<local_data::Map>);
@ -79,7 +79,7 @@ pub enum BlockedTask {
/// Per-task state related to task death, killing, failure, etc.
pub struct Death {
pub on_exit: Option<proc(Result):Send>,
pub on_exit: Option<proc(Result): Send>,
}
pub struct BlockedTasks {
@ -177,7 +177,7 @@ impl Task {
/// Inserts a runtime object into this task, transferring ownership to the
/// task. It is illegal to replace a previous runtime object in this task
/// with this argument.
pub fn put_runtime(&mut self, ops: Box<Runtime:Send>) {
pub fn put_runtime(&mut self, ops: Box<Runtime + Send>) {
assert!(self.imp.is_none());
self.imp = Some(ops);
}
@ -207,7 +207,7 @@ impl Task {
Ok(t) => Some(t),
Err(t) => {
let data = mem::transmute::<_, raw::TraitObject>(t).data;
let obj: Box<Runtime:Send> =
let obj: Box<Runtime + Send> =
mem::transmute(raw::TraitObject {
vtable: vtable,
data: data,
@ -221,7 +221,7 @@ impl Task {
/// Spawns a sibling to this task. The newly spawned task is configured with
/// the `opts` structure and will run `f` as the body of its code.
pub fn spawn_sibling(mut ~self, opts: TaskOpts, f: proc():Send) {
pub fn spawn_sibling(mut ~self, opts: TaskOpts, f: proc(): Send) {
let ops = self.imp.take_unwrap();
ops.spawn_sibling(self, opts, f)
}

View file

@ -78,15 +78,15 @@ use uw = libunwind;
pub struct Unwinder {
unwinding: bool,
cause: Option<Box<Any:Send>>
cause: Option<Box<Any + Send>>
}
struct Exception {
uwe: uw::_Unwind_Exception,
cause: Option<Box<Any:Send>>,
cause: Option<Box<Any + Send>>,
}
pub type Callback = fn(msg: &Any:Send, file: &'static str, line: uint);
pub type Callback = fn(msg: &Any + Send, file: &'static str, line: uint);
// Variables used for invoking callbacks when a task starts to unwind.
//
@ -148,7 +148,7 @@ impl Unwinder {
/// guaranteed that a rust task is in place when invoking this function.
/// Unwinding twice can lead to resource leaks where some destructors are not
/// run.
pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any:Send>> {
pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> {
let closure: Closure = mem::transmute(f);
let ep = rust_try(try_fn, closure.code as *c_void,
closure.env as *c_void);
@ -187,7 +187,7 @@ pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any:Send>> {
// An uninlined, unmangled function upon which to slap yer breakpoints
#[inline(never)]
#[no_mangle]
fn rust_fail(cause: Box<Any:Send>) -> ! {
fn rust_fail(cause: Box<Any + Send>) -> ! {
rtdebug!("begin_unwind()");
unsafe {
@ -457,7 +457,7 @@ pub fn begin_unwind<M: Any + Send>(msg: M, file: &'static str, line: uint) -> !
/// Do this split took the LLVM IR line counts of `fn main() { fail!()
/// }` from ~1900/3700 (-O/no opts) to 180/590.
#[inline(never)] #[cold] // this is the slow path, please never inline this
fn begin_unwind_inner(msg: Box<Any:Send>,
fn begin_unwind_inner(msg: Box<Any + Send>,
file: &'static str,
line: uint) -> ! {
// First, invoke call the user-defined callbacks triggered on task failure.