diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-01-07 13:39:55 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-01-07 15:14:55 +1100 |
| commit | 65ce505819b0f2e06ed39802d293bff182aedc16 (patch) | |
| tree | 4d28b7ab729707ba7ea78dfc37226ec4f1761ee4 /src/libnative/task.rs | |
| parent | 1f1838ea3e6795487521d4541bbd877d8e0797b8 (diff) | |
| download | rust-65ce505819b0f2e06ed39802d293bff182aedc16.tar.gz rust-65ce505819b0f2e06ed39802d293bff182aedc16.zip | |
std::rt: require known stack bounds for all tasks.
We just approximate with a 1 or 2 MB stack for native::start.
Diffstat (limited to 'src/libnative/task.rs')
| -rw-r--r-- | src/libnative/task.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libnative/task.rs b/src/libnative/task.rs index 5a1ef5c836e..73ad5618e3a 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -30,9 +30,11 @@ use task; use bookeeping; /// Creates a new Task which is ready to execute as a 1:1 task. -pub fn new() -> ~Task { +pub fn new(stack_bounds: (uint, uint)) -> ~Task { let mut task = ~Task::new(); - task.put_runtime(ops() as ~rt::Runtime); + let mut ops = ops(); + ops.stack_bounds = stack_bounds; + task.put_runtime(ops as ~rt::Runtime); return task; } @@ -41,7 +43,8 @@ fn ops() -> ~Ops { lock: unsafe { Mutex::new() }, awoken: false, io: io::IoFactory::new(), - stack_bounds: None, + // these *should* get overwritten + stack_bounds: (0, 0), } } @@ -91,7 +94,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc()) { stack::record_stack_bounds(my_stack - stack + 1024, my_stack); } let mut ops = ops; - ops.stack_bounds = Some((my_stack - stack + 1024, my_stack)); + ops.stack_bounds = (my_stack - stack + 1024, my_stack); let mut f = Some(f); let mut task = task; @@ -111,7 +114,7 @@ struct Ops { // This field holds the known bounds of the stack in (lo, hi) form. Not all // native tasks necessarily know their precise bounds, hence this is // optional. - stack_bounds: Option<(uint, uint)>, + stack_bounds: (uint, uint), } impl rt::Runtime for Ops { @@ -133,7 +136,7 @@ impl rt::Runtime for Ops { self as ~Any } - fn stack_bounds(&self) -> Option<(uint, uint)> { self.stack_bounds } + fn stack_bounds(&self) -> (uint, uint) { self.stack_bounds } // This function gets a little interesting. There are a few safety and // ownership violations going on here, but this is all done in the name of |
