convert most of libcore records into structs
This commit is contained in:
parent
6e2ae2c2c1
commit
e4d4a1499b
7 changed files with 105 additions and 86 deletions
|
@ -87,7 +87,10 @@ unsafe fn get_safe_point_count() -> uint {
|
||||||
return *module_meta;
|
return *module_meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
type SafePoint = { sp_meta: *Word, fn_meta: *Word };
|
struct SafePoint {
|
||||||
|
sp_meta: *Word,
|
||||||
|
fn_meta: *Word,
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the safe point metadata for the given program counter, if
|
// Returns the safe point metadata for the given program counter, if
|
||||||
// any.
|
// any.
|
||||||
|
@ -106,7 +109,10 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
|
||||||
let sp: **Word = bump(safe_points, spi*3);
|
let sp: **Word = bump(safe_points, spi*3);
|
||||||
let sp_loc = *sp;
|
let sp_loc = *sp;
|
||||||
if sp_loc == pc {
|
if sp_loc == pc {
|
||||||
return Some({sp_meta: *bump(sp, 1), fn_meta: *bump(sp, 2)});
|
return Some(SafePoint {
|
||||||
|
sp_meta: *bump(sp, 1),
|
||||||
|
fn_meta: *bump(sp, 2),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
spi += 1;
|
spi += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1086,11 +1086,9 @@ pub fn read_whole_file(file: &Path) -> Result<~[u8], ~str> {
|
||||||
// fsync related
|
// fsync related
|
||||||
|
|
||||||
pub mod fsync {
|
pub mod fsync {
|
||||||
|
use prelude::*;
|
||||||
use io::{FILERes, FdRes, fd_t};
|
use io::{FILERes, FdRes, fd_t};
|
||||||
use kinds::Copy;
|
|
||||||
use libc;
|
use libc;
|
||||||
use option::Option;
|
|
||||||
use option;
|
|
||||||
use os;
|
use os;
|
||||||
|
|
||||||
pub enum Level {
|
pub enum Level {
|
||||||
|
@ -1127,11 +1125,11 @@ pub mod fsync {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Arg<t> = {
|
pub struct Arg<t> {
|
||||||
val: t,
|
val: t,
|
||||||
opt_level: Option<Level>,
|
opt_level: Option<Level>,
|
||||||
fsync_fn: fn@(f: t, Level) -> int
|
fsync_fn: fn@(f: t, Level) -> int,
|
||||||
};
|
}
|
||||||
|
|
||||||
// fsync file after executing blk
|
// fsync file after executing blk
|
||||||
// FIXME (#2004) find better way to create resources within lifetime of
|
// FIXME (#2004) find better way to create resources within lifetime of
|
||||||
|
@ -1139,7 +1137,7 @@ pub mod fsync {
|
||||||
pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>,
|
pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>,
|
||||||
blk: fn(v: Res<*libc::FILE>)) {
|
blk: fn(v: Res<*libc::FILE>)) {
|
||||||
unsafe {
|
unsafe {
|
||||||
blk(move Res({
|
blk(Res(Arg {
|
||||||
val: file.f, opt_level: opt_level,
|
val: file.f, opt_level: opt_level,
|
||||||
fsync_fn: fn@(file: *libc::FILE, l: Level) -> int {
|
fsync_fn: fn@(file: *libc::FILE, l: Level) -> int {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1153,7 +1151,7 @@ pub mod fsync {
|
||||||
// fsync fd after executing blk
|
// fsync fd after executing blk
|
||||||
pub fn fd_res_sync(fd: &FdRes, opt_level: Option<Level>,
|
pub fn fd_res_sync(fd: &FdRes, opt_level: Option<Level>,
|
||||||
blk: fn(v: Res<fd_t>)) {
|
blk: fn(v: Res<fd_t>)) {
|
||||||
blk(move Res({
|
blk(Res(Arg {
|
||||||
val: fd.fd, opt_level: opt_level,
|
val: fd.fd, opt_level: opt_level,
|
||||||
fsync_fn: fn@(fd: fd_t, l: Level) -> int {
|
fsync_fn: fn@(fd: fd_t, l: Level) -> int {
|
||||||
return os::fsync_fd(fd, l) as int;
|
return os::fsync_fd(fd, l) as int;
|
||||||
|
@ -1167,7 +1165,7 @@ pub mod fsync {
|
||||||
// Call o.fsync after executing blk
|
// Call o.fsync after executing blk
|
||||||
pub fn obj_sync(o: FSyncable, opt_level: Option<Level>,
|
pub fn obj_sync(o: FSyncable, opt_level: Option<Level>,
|
||||||
blk: fn(v: Res<FSyncable>)) {
|
blk: fn(v: Res<FSyncable>)) {
|
||||||
blk(Res({
|
blk(Res(Arg {
|
||||||
val: o, opt_level: opt_level,
|
val: o, opt_level: opt_level,
|
||||||
fsync_fn: fn@(o: FSyncable, l: Level) -> int {
|
fsync_fn: fn@(o: FSyncable, l: Level) -> int {
|
||||||
return o.fsync(l);
|
return o.fsync(l);
|
||||||
|
|
|
@ -42,7 +42,10 @@ pub trait Rng {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A value with a particular weight compared to other values
|
/// A value with a particular weight compared to other values
|
||||||
pub type Weighted<T> = { weight: uint, item: T };
|
pub struct Weighted<T> {
|
||||||
|
weight: uint,
|
||||||
|
item: T,
|
||||||
|
}
|
||||||
|
|
||||||
/// Extension methods for random number generators
|
/// Extension methods for random number generators
|
||||||
impl Rng {
|
impl Rng {
|
||||||
|
@ -312,12 +315,12 @@ pub fn seeded_rng(seed: &~[u8]) -> Rng {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type XorShiftState = {
|
struct XorShiftState {
|
||||||
mut x: u32,
|
mut x: u32,
|
||||||
mut y: u32,
|
mut y: u32,
|
||||||
mut z: u32,
|
mut z: u32,
|
||||||
mut w: u32
|
mut w: u32,
|
||||||
};
|
}
|
||||||
|
|
||||||
impl XorShiftState: Rng {
|
impl XorShiftState: Rng {
|
||||||
fn next() -> u32 {
|
fn next() -> u32 {
|
||||||
|
@ -338,7 +341,7 @@ pub pure fn xorshift() -> Rng {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng {
|
pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng {
|
||||||
{mut x: x, mut y: y, mut z: z, mut w: w} as Rng
|
XorShiftState { x: x, y: y, z: z, w: w } as Rng
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -492,21 +495,24 @@ pub mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn choose_weighted() {
|
pub fn choose_weighted() {
|
||||||
let r = rand::Rng();
|
let r = rand::Rng();
|
||||||
assert r.choose_weighted(~[{weight: 1u, item: 42}]) == 42;
|
|
||||||
assert r.choose_weighted(~[
|
assert r.choose_weighted(~[
|
||||||
{weight: 0u, item: 42},
|
rand::Weighted { weight: 1u, item: 42 },
|
||||||
{weight: 1u, item: 43}
|
]) == 42;
|
||||||
|
assert r.choose_weighted(~[
|
||||||
|
rand::Weighted { weight: 0u, item: 42 },
|
||||||
|
rand::Weighted { weight: 1u, item: 43 },
|
||||||
]) == 43;
|
]) == 43;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn choose_weighted_option() {
|
pub fn choose_weighted_option() {
|
||||||
let r = rand::Rng();
|
let r = rand::Rng();
|
||||||
assert r.choose_weighted_option(~[{weight: 1u, item: 42}]) ==
|
|
||||||
Some(42);
|
|
||||||
assert r.choose_weighted_option(~[
|
assert r.choose_weighted_option(~[
|
||||||
{weight: 0u, item: 42},
|
rand::Weighted { weight: 1u, item: 42 },
|
||||||
{weight: 1u, item: 43}
|
]) == Some(42);
|
||||||
|
assert r.choose_weighted_option(~[
|
||||||
|
rand::Weighted { weight: 0u, item: 42 },
|
||||||
|
rand::Weighted { weight: 1u, item: 43 },
|
||||||
]) == Some(43);
|
]) == Some(43);
|
||||||
let v: Option<int> = r.choose_weighted_option([]);
|
let v: Option<int> = r.choose_weighted_option([]);
|
||||||
assert v.is_none();
|
assert v.is_none();
|
||||||
|
@ -518,9 +524,9 @@ pub mod tests {
|
||||||
let empty: ~[int] = ~[];
|
let empty: ~[int] = ~[];
|
||||||
assert r.weighted_vec(~[]) == empty;
|
assert r.weighted_vec(~[]) == empty;
|
||||||
assert r.weighted_vec(~[
|
assert r.weighted_vec(~[
|
||||||
{weight: 0u, item: 3u},
|
rand::Weighted { weight: 0u, item: 3u },
|
||||||
{weight: 1u, item: 2u},
|
rand::Weighted { weight: 1u, item: 2u },
|
||||||
{weight: 2u, item: 1u}
|
rand::Weighted { weight: 2u, item: 1u },
|
||||||
]) == ~[2u, 1u, 1u];
|
]) == ~[2u, 1u, 1u];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,11 +220,13 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
|
||||||
libc::close(pipe_err.out);
|
libc::close(pipe_err.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProgRepr = {pid: pid_t,
|
struct ProgRepr {
|
||||||
mut in_fd: c_int,
|
pid: pid_t,
|
||||||
out_file: *libc::FILE,
|
mut in_fd: c_int,
|
||||||
err_file: *libc::FILE,
|
out_file: *libc::FILE,
|
||||||
mut finished: bool};
|
err_file: *libc::FILE,
|
||||||
|
mut finished: bool,
|
||||||
|
}
|
||||||
|
|
||||||
fn close_repr_input(r: &ProgRepr) {
|
fn close_repr_input(r: &ProgRepr) {
|
||||||
let invalid_fd = -1i32;
|
let invalid_fd = -1i32;
|
||||||
|
@ -274,12 +276,15 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
|
||||||
fn finish() -> int { finish_repr(&self.r) }
|
fn finish() -> int { finish_repr(&self.r) }
|
||||||
fn destroy() { destroy_repr(&self.r); }
|
fn destroy() { destroy_repr(&self.r); }
|
||||||
}
|
}
|
||||||
let repr = {pid: pid,
|
let repr = ProgRepr {
|
||||||
mut in_fd: pipe_input.out,
|
pid: pid,
|
||||||
out_file: os::fdopen(pipe_output.in),
|
in_fd: pipe_input.out,
|
||||||
err_file: os::fdopen(pipe_err.in),
|
out_file: os::fdopen(pipe_output.in),
|
||||||
mut finished: false};
|
err_file: os::fdopen(pipe_err.in),
|
||||||
return ProgRes(move repr) as Program;
|
finished: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
ProgRes(repr) as Program
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,10 +168,10 @@ impl SchedMode : cmp::Eq {
|
||||||
* default these foreign stacks have unspecified size, but with this
|
* default these foreign stacks have unspecified size, but with this
|
||||||
* option their size can be precisely specified.
|
* option their size can be precisely specified.
|
||||||
*/
|
*/
|
||||||
pub type SchedOpts = {
|
pub struct SchedOpts {
|
||||||
mode: SchedMode,
|
mode: SchedMode,
|
||||||
foreign_stack_size: Option<uint>
|
foreign_stack_size: Option<uint>,
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task configuration options
|
* Task configuration options
|
||||||
|
@ -200,12 +200,12 @@ pub type SchedOpts = {
|
||||||
* into foreign code that blocks. Without doing so in a different
|
* into foreign code that blocks. Without doing so in a different
|
||||||
* scheduler other tasks will be impeded or even blocked indefinitely.
|
* scheduler other tasks will be impeded or even blocked indefinitely.
|
||||||
*/
|
*/
|
||||||
pub type TaskOpts = {
|
pub struct TaskOpts {
|
||||||
linked: bool,
|
linked: bool,
|
||||||
supervised: bool,
|
supervised: bool,
|
||||||
mut notify_chan: Option<Chan<TaskResult>>,
|
mut notify_chan: Option<Chan<TaskResult>>,
|
||||||
sched: Option<SchedOpts>,
|
sched: Option<SchedOpts>,
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The task builder type.
|
* The task builder type.
|
||||||
|
@ -251,15 +251,15 @@ priv impl TaskBuilder {
|
||||||
self.consumed = true;
|
self.consumed = true;
|
||||||
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
||||||
TaskBuilder {
|
TaskBuilder {
|
||||||
opts: {
|
opts: TaskOpts {
|
||||||
linked: self.opts.linked,
|
linked: self.opts.linked,
|
||||||
supervised: self.opts.supervised,
|
supervised: self.opts.supervised,
|
||||||
mut notify_chan: move notify_chan,
|
notify_chan: notify_chan,
|
||||||
sched: self.opts.sched
|
sched: self.opts.sched
|
||||||
},
|
},
|
||||||
gen_body: self.gen_body,
|
gen_body: self.gen_body,
|
||||||
can_not_copy: None,
|
can_not_copy: None,
|
||||||
mut consumed: false
|
consumed: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,10 +272,10 @@ impl TaskBuilder {
|
||||||
fn unlinked() -> TaskBuilder {
|
fn unlinked() -> TaskBuilder {
|
||||||
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
||||||
TaskBuilder {
|
TaskBuilder {
|
||||||
opts: {
|
opts: TaskOpts {
|
||||||
linked: false,
|
linked: false,
|
||||||
supervised: self.opts.supervised,
|
supervised: self.opts.supervised,
|
||||||
mut notify_chan: move notify_chan,
|
notify_chan: notify_chan,
|
||||||
sched: self.opts.sched
|
sched: self.opts.sched
|
||||||
},
|
},
|
||||||
can_not_copy: None,
|
can_not_copy: None,
|
||||||
|
@ -290,10 +290,10 @@ impl TaskBuilder {
|
||||||
fn supervised() -> TaskBuilder {
|
fn supervised() -> TaskBuilder {
|
||||||
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
||||||
TaskBuilder {
|
TaskBuilder {
|
||||||
opts: {
|
opts: TaskOpts {
|
||||||
linked: false,
|
linked: false,
|
||||||
supervised: true,
|
supervised: true,
|
||||||
mut notify_chan: move notify_chan,
|
notify_chan: notify_chan,
|
||||||
sched: self.opts.sched
|
sched: self.opts.sched
|
||||||
},
|
},
|
||||||
can_not_copy: None,
|
can_not_copy: None,
|
||||||
|
@ -307,10 +307,10 @@ impl TaskBuilder {
|
||||||
fn linked() -> TaskBuilder {
|
fn linked() -> TaskBuilder {
|
||||||
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
||||||
TaskBuilder {
|
TaskBuilder {
|
||||||
opts: {
|
opts: TaskOpts {
|
||||||
linked: true,
|
linked: true,
|
||||||
supervised: false,
|
supervised: false,
|
||||||
mut notify_chan: move notify_chan,
|
notify_chan: notify_chan,
|
||||||
sched: self.opts.sched
|
sched: self.opts.sched
|
||||||
},
|
},
|
||||||
can_not_copy: None,
|
can_not_copy: None,
|
||||||
|
@ -352,10 +352,10 @@ impl TaskBuilder {
|
||||||
|
|
||||||
// Reconfigure self to use a notify channel.
|
// Reconfigure self to use a notify channel.
|
||||||
TaskBuilder {
|
TaskBuilder {
|
||||||
opts: {
|
opts: TaskOpts {
|
||||||
linked: self.opts.linked,
|
linked: self.opts.linked,
|
||||||
supervised: self.opts.supervised,
|
supervised: self.opts.supervised,
|
||||||
mut notify_chan: Some(move notify_pipe_ch),
|
notify_chan: Some(notify_pipe_ch),
|
||||||
sched: self.opts.sched
|
sched: self.opts.sched
|
||||||
},
|
},
|
||||||
can_not_copy: None,
|
can_not_copy: None,
|
||||||
|
@ -366,11 +366,14 @@ impl TaskBuilder {
|
||||||
fn sched_mode(mode: SchedMode) -> TaskBuilder {
|
fn sched_mode(mode: SchedMode) -> TaskBuilder {
|
||||||
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
||||||
TaskBuilder {
|
TaskBuilder {
|
||||||
opts: {
|
opts: TaskOpts {
|
||||||
linked: self.opts.linked,
|
linked: self.opts.linked,
|
||||||
supervised: self.opts.supervised,
|
supervised: self.opts.supervised,
|
||||||
mut notify_chan: move notify_chan,
|
notify_chan: notify_chan,
|
||||||
sched: Some({ mode: mode, foreign_stack_size: None})
|
sched: Some(SchedOpts {
|
||||||
|
mode: mode,
|
||||||
|
foreign_stack_size: None,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
can_not_copy: None,
|
can_not_copy: None,
|
||||||
.. self.consume()
|
.. self.consume()
|
||||||
|
@ -393,10 +396,10 @@ impl TaskBuilder {
|
||||||
let prev_gen_body = self.gen_body;
|
let prev_gen_body = self.gen_body;
|
||||||
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
||||||
TaskBuilder {
|
TaskBuilder {
|
||||||
opts: {
|
opts: TaskOpts {
|
||||||
linked: self.opts.linked,
|
linked: self.opts.linked,
|
||||||
supervised: self.opts.supervised,
|
supervised: self.opts.supervised,
|
||||||
mut notify_chan: move notify_chan,
|
notify_chan: notify_chan,
|
||||||
sched: self.opts.sched
|
sched: self.opts.sched
|
||||||
},
|
},
|
||||||
// tjc: I think this is the line that gets miscompiled
|
// tjc: I think this is the line that gets miscompiled
|
||||||
|
@ -424,10 +427,10 @@ impl TaskBuilder {
|
||||||
fn spawn(f: fn~()) {
|
fn spawn(f: fn~()) {
|
||||||
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
let notify_chan = replace(&mut self.opts.notify_chan, None);
|
||||||
let x = self.consume();
|
let x = self.consume();
|
||||||
let opts = {
|
let opts = TaskOpts {
|
||||||
linked: x.opts.linked,
|
linked: x.opts.linked,
|
||||||
supervised: x.opts.supervised,
|
supervised: x.opts.supervised,
|
||||||
mut notify_chan: move notify_chan,
|
notify_chan: notify_chan,
|
||||||
sched: x.opts.sched
|
sched: x.opts.sched
|
||||||
};
|
};
|
||||||
spawn::spawn_raw(move opts, (x.gen_body)(move f));
|
spawn::spawn_raw(move opts, (x.gen_body)(move f));
|
||||||
|
@ -482,10 +485,10 @@ pub fn default_task_opts() -> TaskOpts {
|
||||||
* into the same scheduler, and do not post lifecycle notifications.
|
* into the same scheduler, and do not post lifecycle notifications.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
TaskOpts {
|
||||||
linked: true,
|
linked: true,
|
||||||
supervised: false,
|
supervised: false,
|
||||||
mut notify_chan: None,
|
notify_chan: None,
|
||||||
sched: None
|
sched: None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,14 +114,14 @@ pub fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// One of these per group of linked-failure tasks.
|
// One of these per group of linked-failure tasks.
|
||||||
type TaskGroupData = {
|
struct TaskGroupData {
|
||||||
// All tasks which might kill this group. When this is empty, the group
|
// All tasks which might kill this group. When this is empty, the group
|
||||||
// can be "GC"ed (i.e., its link in the ancestor list can be removed).
|
// can be "GC"ed (i.e., its link in the ancestor list can be removed).
|
||||||
mut members: TaskSet,
|
mut members: TaskSet,
|
||||||
// All tasks unidirectionally supervised by (directly or transitively)
|
// All tasks unidirectionally supervised by (directly or transitively)
|
||||||
// tasks in this group.
|
// tasks in this group.
|
||||||
mut descendants: TaskSet,
|
mut descendants: TaskSet,
|
||||||
};
|
}
|
||||||
type TaskGroupArc = private::Exclusive<Option<TaskGroupData>>;
|
type TaskGroupArc = private::Exclusive<Option<TaskGroupData>>;
|
||||||
|
|
||||||
type TaskGroupInner = &mut Option<TaskGroupData>;
|
type TaskGroupInner = &mut Option<TaskGroupData>;
|
||||||
|
@ -138,7 +138,7 @@ pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool {
|
||||||
// taskgroup which was spawned-unlinked. Tasks from intermediate generations
|
// taskgroup which was spawned-unlinked. Tasks from intermediate generations
|
||||||
// have references to the middle of the list; when intermediate generations
|
// have references to the middle of the list; when intermediate generations
|
||||||
// die, their node in the list will be collected at a descendant's spawn-time.
|
// die, their node in the list will be collected at a descendant's spawn-time.
|
||||||
type AncestorNode = {
|
struct AncestorNode {
|
||||||
// Since the ancestor list is recursive, we end up with references to
|
// Since the ancestor list is recursive, we end up with references to
|
||||||
// exclusives within other exclusives. This is dangerous business (if
|
// exclusives within other exclusives. This is dangerous business (if
|
||||||
// circular references arise, deadlock and memory leaks are imminent).
|
// circular references arise, deadlock and memory leaks are imminent).
|
||||||
|
@ -150,7 +150,8 @@ type AncestorNode = {
|
||||||
mut parent_group: Option<TaskGroupArc>,
|
mut parent_group: Option<TaskGroupArc>,
|
||||||
// Recursive rest of the list.
|
// Recursive rest of the list.
|
||||||
mut ancestors: AncestorList,
|
mut ancestors: AncestorList,
|
||||||
};
|
}
|
||||||
|
|
||||||
enum AncestorList = Option<private::Exclusive<AncestorNode>>;
|
enum AncestorList = Option<private::Exclusive<AncestorNode>>;
|
||||||
|
|
||||||
// Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety.
|
// Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety.
|
||||||
|
@ -450,11 +451,10 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
|
||||||
// Main task, doing first spawn ever. Lazily initialise here.
|
// Main task, doing first spawn ever. Lazily initialise here.
|
||||||
let mut members = new_taskset();
|
let mut members = new_taskset();
|
||||||
taskset_insert(&mut members, spawner);
|
taskset_insert(&mut members, spawner);
|
||||||
let tasks =
|
let tasks = private::exclusive(Some(TaskGroupData {
|
||||||
private::exclusive(Some({
|
members: members,
|
||||||
mut members: move members,
|
descendants: new_taskset(),
|
||||||
mut descendants: new_taskset()
|
}));
|
||||||
}));
|
|
||||||
// Main task/group has no ancestors, no notifier, etc.
|
// Main task/group has no ancestors, no notifier, etc.
|
||||||
let group =
|
let group =
|
||||||
@TCB(spawner, move tasks, AncestorList(None), true, None);
|
@TCB(spawner, move tasks, AncestorList(None), true, None);
|
||||||
|
@ -475,9 +475,9 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
|
||||||
(move g, move a, spawner_group.is_main)
|
(move g, move a, spawner_group.is_main)
|
||||||
} else {
|
} else {
|
||||||
// Child is in a separate group from spawner.
|
// Child is in a separate group from spawner.
|
||||||
let g = private::exclusive(Some({
|
let g = private::exclusive(Some(TaskGroupData {
|
||||||
mut members: new_taskset(),
|
members: new_taskset(),
|
||||||
mut descendants: new_taskset()
|
descendants: new_taskset(),
|
||||||
}));
|
}));
|
||||||
let a = if supervised {
|
let a = if supervised {
|
||||||
// Child's ancestors start with the spawner.
|
// Child's ancestors start with the spawner.
|
||||||
|
@ -495,10 +495,11 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
|
||||||
};
|
};
|
||||||
assert new_generation < uint::max_value;
|
assert new_generation < uint::max_value;
|
||||||
// Build a new node in the ancestor list.
|
// Build a new node in the ancestor list.
|
||||||
AncestorList(Some(private::exclusive(
|
AncestorList(Some(private::exclusive(AncestorNode {
|
||||||
{ generation: new_generation,
|
generation: new_generation,
|
||||||
mut parent_group: Some(spawner_group.tasks.clone()),
|
parent_group: Some(spawner_group.tasks.clone()),
|
||||||
mut ancestors: move old_ancestors })))
|
ancestors: old_ancestors,
|
||||||
|
})))
|
||||||
} else {
|
} else {
|
||||||
// Child has no ancestors.
|
// Child has no ancestors.
|
||||||
AncestorList(None)
|
AncestorList(None)
|
||||||
|
@ -685,9 +686,9 @@ fn test_spawn_raw_simple() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore(cfg(windows))]
|
#[ignore(cfg(windows))]
|
||||||
fn test_spawn_raw_unsupervise() {
|
fn test_spawn_raw_unsupervise() {
|
||||||
let opts = {
|
let opts = task::TaskOpts {
|
||||||
linked: false,
|
linked: false,
|
||||||
mut notify_chan: None,
|
notify_chan: None,
|
||||||
.. default_task_opts()
|
.. default_task_opts()
|
||||||
};
|
};
|
||||||
do spawn_raw(move opts) {
|
do spawn_raw(move opts) {
|
||||||
|
@ -700,8 +701,8 @@ fn test_spawn_raw_unsupervise() {
|
||||||
fn test_spawn_raw_notify_success() {
|
fn test_spawn_raw_notify_success() {
|
||||||
let (notify_po, notify_ch) = pipes::stream();
|
let (notify_po, notify_ch) = pipes::stream();
|
||||||
|
|
||||||
let opts = {
|
let opts = task::TaskOpts {
|
||||||
notify_chan: Some(move notify_ch),
|
notify_chan: Some(notify_ch),
|
||||||
.. default_task_opts()
|
.. default_task_opts()
|
||||||
};
|
};
|
||||||
do spawn_raw(move opts) {
|
do spawn_raw(move opts) {
|
||||||
|
@ -715,9 +716,9 @@ fn test_spawn_raw_notify_failure() {
|
||||||
// New bindings for these
|
// New bindings for these
|
||||||
let (notify_po, notify_ch) = pipes::stream();
|
let (notify_po, notify_ch) = pipes::stream();
|
||||||
|
|
||||||
let opts = {
|
let opts = task::TaskOpts {
|
||||||
linked: false,
|
linked: false,
|
||||||
notify_chan: Some(move notify_ch),
|
notify_chan: Some(notify_ch),
|
||||||
.. default_task_opts()
|
.. default_task_opts()
|
||||||
};
|
};
|
||||||
do spawn_raw(move opts) {
|
do spawn_raw(move opts) {
|
||||||
|
|
|
@ -2027,10 +2027,10 @@ pub mod raw {
|
||||||
unboxed: UnboxedVecRepr
|
unboxed: UnboxedVecRepr
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type SliceRepr = {
|
pub struct SliceRepr {
|
||||||
mut data: *u8,
|
mut data: *u8,
|
||||||
mut len: uint
|
mut len: uint
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the length of a vector
|
* Sets the length of a vector
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue