core: Remove the unused Notification enum
This commit is contained in:
parent
b6bde885dc
commit
f6d2a71436
@ -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<Chan<Notification>>,
|
||||
mut notify_chan: Option<Chan<TaskResult>>,
|
||||
sched: Option<SchedOpts>,
|
||||
};
|
||||
|
||||
@ -344,12 +325,10 @@ impl TaskBuilder {
|
||||
}
|
||||
|
||||
// Construct the future and give it to the caller.
|
||||
let (notify_pipe_ch, notify_pipe_po) = stream::<Notification>();
|
||||
let (notify_pipe_ch, notify_pipe_po) = stream::<TaskResult>();
|
||||
|
||||
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.
|
||||
|
@ -320,15 +320,15 @@ fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
|
||||
}
|
||||
|
||||
struct AutoNotify {
|
||||
notify_chan: Chan<Notification>,
|
||||
notify_chan: Chan<TaskResult>,
|
||||
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<Notification>) -> AutoNotify {
|
||||
fn AutoNotify(chan: Chan<TaskResult>) -> 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<Chan<Notification>>,
|
||||
notify_chan: Option<Chan<TaskResult>>,
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user