Remove unnecessary unwind messages
Now that the type_id intrinsic is working across crates, all of these unnecessary messages can be removed to have the failure type for a task truly be ~Any and only ~Any
This commit is contained in:
parent
61637439dc
commit
b00449380f
5 changed files with 41 additions and 76 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue