Skip to content

Commit f6d2a71

Browse files
committed
core: Remove the unused Notification enum
1 parent b6bde88 commit f6d2a71

File tree

2 files changed

+11
-38
lines changed

2 files changed

+11
-38
lines changed

src/libcore/task.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,6 @@ impl TaskResult : Eq {
7373
pure fn ne(other: &TaskResult) -> bool { !self.eq(other) }
7474
}
7575

76-
/// A message type for notifying of task lifecycle events
77-
pub enum Notification {
78-
/// Sent when a task exits with the task handle and result
79-
Exit(Task, TaskResult)
80-
}
81-
82-
impl Notification : cmp::Eq {
83-
pure fn eq(other: &Notification) -> bool {
84-
match self {
85-
Exit(e0a, e1a) => {
86-
match (*other) {
87-
Exit(e0b, e1b) => e0a == e0b && e1a == e1b
88-
}
89-
}
90-
}
91-
}
92-
pure fn ne(other: &Notification) -> bool { !self.eq(other) }
93-
}
94-
9576
/// Scheduler modes
9677
pub enum SchedMode {
9778
/// All tasks run in the same OS thread
@@ -201,7 +182,7 @@ pub type SchedOpts = {
201182
pub type TaskOpts = {
202183
linked: bool,
203184
supervised: bool,
204-
mut notify_chan: Option<Chan<Notification>>,
185+
mut notify_chan: Option<Chan<TaskResult>>,
205186
sched: Option<SchedOpts>,
206187
};
207188

@@ -344,12 +325,10 @@ impl TaskBuilder {
344325
}
345326
346327
// Construct the future and give it to the caller.
347-
let (notify_pipe_ch, notify_pipe_po) = stream::<Notification>();
328+
let (notify_pipe_ch, notify_pipe_po) = stream::<TaskResult>();
348329
349330
blk(do future::from_fn |move notify_pipe_po| {
350-
match notify_pipe_po.recv() {
351-
Exit(_, result) => result
352-
}
331+
notify_pipe_po.recv()
353332
});
354333
355334
// Reconfigure self to use a notify channel.

src/libcore/task/spawn.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
320320
}
321321

322322
struct AutoNotify {
323-
notify_chan: Chan<Notification>,
323+
notify_chan: Chan<TaskResult>,
324324
mut failed: bool,
325325
drop {
326326
let result = if self.failed { Failure } else { Success };
327-
self.notify_chan.send(Exit(get_task(), result));
327+
self.notify_chan.send(result);
328328
}
329329
}
330330

331-
fn AutoNotify(chan: Chan<Notification>) -> AutoNotify {
331+
fn AutoNotify(chan: Chan<TaskResult>) -> AutoNotify {
332332
AutoNotify {
333333
notify_chan: move chan,
334334
failed: true // Un-set above when taskgroup successfully made.
@@ -532,7 +532,7 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
532532
// (4) ...and runs the provided body function.
533533
fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc,
534534
ancestors: AncestorList, is_main: bool,
535-
notify_chan: Option<Chan<Notification>>,
535+
notify_chan: Option<Chan<TaskResult>>,
536536
f: fn~()) -> fn~() {
537537
let child_data = ~mut Some((move child_arc, move ancestors));
538538
return fn~(move notify_chan, move child_data, move f) {
@@ -660,36 +660,30 @@ fn test_spawn_raw_unsupervise() {
660660
#[test]
661661
#[ignore(cfg(windows))]
662662
fn test_spawn_raw_notify_success() {
663-
let (task_ch, task_po) = pipes::stream();
664663
let (notify_ch, notify_po) = pipes::stream();
665664

666665
let opts = {
667666
notify_chan: Some(move notify_ch),
668667
.. default_task_opts()
669668
};
670-
do spawn_raw(move opts) |move task_ch| {
671-
task_ch.send(get_task());
669+
do spawn_raw(move opts) {
672670
}
673-
let task_ = task_po.recv();
674-
assert notify_po.recv() == Exit(task_, Success);
671+
assert notify_po.recv() == Success;
675672
}
676673

677674
#[test]
678675
#[ignore(cfg(windows))]
679676
fn test_spawn_raw_notify_failure() {
680677
// New bindings for these
681-
let (task_ch, task_po) = pipes::stream();
682678
let (notify_ch, notify_po) = pipes::stream();
683679

684680
let opts = {
685681
linked: false,
686682
notify_chan: Some(move notify_ch),
687683
.. default_task_opts()
688684
};
689-
do spawn_raw(move opts) |move task_ch| {
690-
task_ch.send(get_task());
685+
do spawn_raw(move opts) {
691686
fail;
692687
}
693-
let task_ = task_po.recv();
694-
assert notify_po.recv() == Exit(task_, Failure);
688+
assert notify_po.recv() == Failure;
695689
}

0 commit comments

Comments
 (0)