@@ -30,10 +30,11 @@ use task;
30
30
use std:: task:: { TaskBuilder , Spawner } ;
31
31
32
32
/// Creates a new Task which is ready to execute as a 1:1 task.
33
- pub fn new ( stack_bounds : ( uint , uint ) ) -> Box < Task > {
33
+ pub fn new ( stack_bounds : ( uint , uint ) , stack_guard : uint ) -> Box < Task > {
34
34
let mut task = box Task :: new ( ) ;
35
35
let mut ops = ops ( ) ;
36
36
ops. stack_bounds = stack_bounds;
37
+ ops. stack_guard = stack_guard;
37
38
task. put_runtime ( ops) ;
38
39
return task;
39
40
}
@@ -45,6 +46,7 @@ fn ops() -> Box<Ops> {
45
46
io : io:: IoFactory :: new ( ) ,
46
47
// these *should* get overwritten
47
48
stack_bounds : ( 0 , 0 ) ,
49
+ stack_guard : 0
48
50
}
49
51
}
50
52
@@ -87,6 +89,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc():Send) {
87
89
stack:: record_os_managed_stack_bounds ( my_stack - stack + 1024 , my_stack) ;
88
90
}
89
91
let mut ops = ops;
92
+ ops. stack_guard = rt:: thread:: current_guard_page ( ) ;
90
93
ops. stack_bounds = ( my_stack - stack + 1024 , my_stack) ;
91
94
92
95
let mut f = Some ( f) ;
@@ -128,6 +131,8 @@ struct Ops {
128
131
// native tasks necessarily know their precise bounds, hence this is
129
132
// optional.
130
133
stack_bounds : ( uint , uint ) ,
134
+
135
+ stack_guard : uint
131
136
}
132
137
133
138
impl rt:: Runtime for Ops {
@@ -151,6 +156,14 @@ impl rt::Runtime for Ops {
151
156
152
157
fn stack_bounds ( & self ) -> ( uint , uint ) { self . stack_bounds }
153
158
159
+ fn stack_guard ( & self ) -> Option < uint > {
160
+ if self . stack_guard != 0 {
161
+ Some ( self . stack_guard )
162
+ } else {
163
+ None
164
+ }
165
+ }
166
+
154
167
fn can_block ( & self ) -> bool { true }
155
168
156
169
// This function gets a little interesting. There are a few safety and
0 commit comments