diff options
| author | bors <bors@rust-lang.org> | 2013-11-04 19:21:50 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-11-04 19:21:50 -0800 |
| commit | 4b04395c11eeb9fa6517a73717184881a977cee4 (patch) | |
| tree | 93326e0289fcf04a85b7048c25dc9175d16de291 /src/libstd/task | |
| parent | 72e432df9dc5f546d522654336a38213af69cac8 (diff) | |
| parent | b00449380f520deb65de26e654aeaba4561ee13f (diff) | |
| download | rust-4b04395c11eeb9fa6517a73717184881a977cee4.tar.gz rust-4b04395c11eeb9fa6517a73717184881a977cee4.zip | |
auto merge of #10182 : alexcrichton/rust/typeid-intrinsic, r=nikomatsakis
This isn't quite as fancy as the struct in #9913, but I'm not sure we should be exposing crate names/hashes of the types. That being said, it'd be pretty easy to extend this (the deterministic hashing regardless of what crate you're in was the hard part).
Diffstat (limited to 'src/libstd/task')
| -rw-r--r-- | src/libstd/task/mod.rs | 23 | ||||
| -rw-r--r-- | src/libstd/task/spawn.rs | 6 |
2 files changed, 11 insertions, 18 deletions
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index cdb70f00dfe..e75f8f6237f 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -60,8 +60,6 @@ use comm::{stream, Chan, GenericChan, GenericPort, Port, Peekable}; use result::{Result, Ok, Err}; use rt::in_green_task_context; use rt::local::Local; -use rt::task::{UnwindMessageAny, UnwindMessageLinked}; -use rt::task::{UnwindMessageStrStatic, UnwindMessageStrOwned}; use rt::task::{UnwindResult, Success, Failure}; use send_str::{SendStr, IntoSendStr}; use unstable::finally::Finally; @@ -90,30 +88,25 @@ pub type TaskResult = Result<(), ~Any>; pub struct LinkedFailure; -#[inline] -fn wrap_as_any(res: UnwindResult) -> TaskResult { - match res { - Success => Ok(()), - Failure(UnwindMessageAny(a)) => Err(a), - Failure(UnwindMessageLinked) => Err(~LinkedFailure as ~Any), - Failure(UnwindMessageStrOwned(s)) => Err(~s as ~Any), - Failure(UnwindMessageStrStatic(s)) => Err(~s as ~Any), - } -} - pub struct TaskResultPort { priv port: Port<UnwindResult> } +fn to_task_result(res: UnwindResult) -> TaskResult { + match res { + Success => Ok(()), Failure(a) => Err(a), + } +} + impl GenericPort<TaskResult> for TaskResultPort { #[inline] fn recv(&self) -> TaskResult { - wrap_as_any(self.port.recv()) + to_task_result(self.port.recv()) } #[inline] fn try_recv(&self) -> Option<TaskResult> { - self.port.try_recv().map(wrap_as_any) + self.port.try_recv().map(to_task_result) } } diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 4a98e396bbc..a4a43a01edd 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -83,11 +83,11 @@ use local_data; use rt::local::Local; use rt::sched::{Scheduler, Shutdown, TaskFromFriend}; use rt::task::{Task, Sched}; -use rt::task::{UnwindMessageLinked, UnwindMessageStrStatic}; use rt::task::{UnwindResult, Success, Failure}; use rt::thread::Thread; use rt::work_queue::WorkQueue; use rt::{in_green_task_context, new_event_loop, KillHandle}; +use task::LinkedFailure; use task::SingleThreaded; use task::TaskOpts; use task::unkillable; @@ -324,7 +324,7 @@ impl Drop for Taskgroup { do RuntimeGlue::with_task_handle_and_failing |me, failing| { if failing { for x in self.notifier.mut_iter() { - x.task_result = Some(Failure(UnwindMessageLinked)); + x.task_result = Some(Failure(~LinkedFailure as ~Any)); } // Take everybody down with us. After this point, every // other task in the group will see 'tg' as none, which @@ -379,7 +379,7 @@ impl AutoNotify { notify_chan: chan, // Un-set above when taskgroup successfully made. - task_result: Some(Failure(UnwindMessageStrStatic("AutoNotify::new()"))) + task_result: Some(Failure(~("AutoNotify::new()") as ~Any)) } } } |
