From f6d2a7143629898aebea58db836eb2009e97d067 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 22 Oct 2012 17:45:20 -0700 Subject: [PATCH] core: Remove the unused Notification enum --- src/libcore/task.rs | 27 +++------------------------ src/libcore/task/spawn.rs | 22 ++++++++-------------- 2 files changed, 11 insertions(+), 38 deletions(-) diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 37ee9ddf96bd..3bfa41f1c482 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -73,25 +73,6 @@ impl TaskResult : Eq { pure fn ne(other: &TaskResult) -> bool { !self.eq(other) } } -/// A message type for notifying of task lifecycle events -pub enum Notification { - /// Sent when a task exits with the task handle and result - Exit(Task, TaskResult) -} - -impl Notification : cmp::Eq { - pure fn eq(other: &Notification) -> bool { - match self { - Exit(e0a, e1a) => { - match (*other) { - Exit(e0b, e1b) => e0a == e0b && e1a == e1b - } - } - } - } - pure fn ne(other: &Notification) -> bool { !self.eq(other) } -} - /// Scheduler modes pub enum SchedMode { /// All tasks run in the same OS thread @@ -201,7 +182,7 @@ pub type SchedOpts = { pub type TaskOpts = { linked: bool, supervised: bool, - mut notify_chan: Option>, + mut notify_chan: Option>, sched: Option, }; @@ -344,12 +325,10 @@ impl TaskBuilder { } // Construct the future and give it to the caller. - let (notify_pipe_ch, notify_pipe_po) = stream::(); + let (notify_pipe_ch, notify_pipe_po) = stream::(); blk(do future::from_fn |move notify_pipe_po| { - match notify_pipe_po.recv() { - Exit(_, result) => result - } + notify_pipe_po.recv() }); // Reconfigure self to use a notify channel. diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 6fbb572df41e..ea66776d22d6 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -320,15 +320,15 @@ fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList, } struct AutoNotify { - notify_chan: Chan, + notify_chan: Chan, mut failed: bool, drop { let result = if self.failed { Failure } else { Success }; - self.notify_chan.send(Exit(get_task(), result)); + self.notify_chan.send(result); } } -fn AutoNotify(chan: Chan) -> AutoNotify { +fn AutoNotify(chan: Chan) -> AutoNotify { AutoNotify { notify_chan: move chan, failed: true // Un-set above when taskgroup successfully made. @@ -532,7 +532,7 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) { // (4) ...and runs the provided body function. fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc, ancestors: AncestorList, is_main: bool, - notify_chan: Option>, + notify_chan: Option>, f: fn~()) -> fn~() { let child_data = ~mut Some((move child_arc, move ancestors)); return fn~(move notify_chan, move child_data, move f) { @@ -660,25 +660,21 @@ fn test_spawn_raw_unsupervise() { #[test] #[ignore(cfg(windows))] fn test_spawn_raw_notify_success() { - let (task_ch, task_po) = pipes::stream(); let (notify_ch, notify_po) = pipes::stream(); let opts = { notify_chan: Some(move notify_ch), .. default_task_opts() }; - do spawn_raw(move opts) |move task_ch| { - task_ch.send(get_task()); + do spawn_raw(move opts) { } - let task_ = task_po.recv(); - assert notify_po.recv() == Exit(task_, Success); + assert notify_po.recv() == Success; } #[test] #[ignore(cfg(windows))] fn test_spawn_raw_notify_failure() { // New bindings for these - let (task_ch, task_po) = pipes::stream(); let (notify_ch, notify_po) = pipes::stream(); let opts = { @@ -686,10 +682,8 @@ fn test_spawn_raw_notify_failure() { notify_chan: Some(move notify_ch), .. default_task_opts() }; - do spawn_raw(move opts) |move task_ch| { - task_ch.send(get_task()); + do spawn_raw(move opts) { fail; } - let task_ = task_po.recv(); - assert notify_po.recv() == Exit(task_, Failure); + assert notify_po.recv() == Failure; }