@@ -29,10 +29,11 @@ use io;
29
29
use std:: task:: { TaskBuilder , Spawner } ;
30
30
31
31
/// Creates a new Task which is ready to execute as a 1:1 task.
32
- pub fn new ( stack_bounds : ( uint , uint ) ) -> Box < Task > {
32
+ pub fn new ( stack_bounds : ( uint , uint ) , stack_guard : uint ) -> Box < Task > {
33
33
let mut task = box Task :: new ( ) ;
34
34
let mut ops = ops ( ) ;
35
35
ops. stack_bounds = stack_bounds;
36
+ ops. stack_guard = stack_guard;
36
37
task. put_runtime ( ops) ;
37
38
return task;
38
39
}
@@ -44,6 +45,7 @@ fn ops() -> Box<Ops> {
44
45
io : io:: IoFactory :: new ( ) ,
45
46
// these *should* get overwritten
46
47
stack_bounds : ( 0 , 0 ) ,
48
+ stack_guard : 0
47
49
}
48
50
}
49
51
@@ -82,6 +84,7 @@ impl Spawner for NativeSpawner {
82
84
my_stack) ;
83
85
}
84
86
let mut ops = ops;
87
+ ops. stack_guard = rt:: thread:: current_guard_page ( ) ;
85
88
ops. stack_bounds = ( my_stack - stack + 1024 , my_stack) ;
86
89
87
90
let mut f = Some ( f) ;
@@ -115,6 +118,8 @@ struct Ops {
115
118
// native tasks necessarily know their precise bounds, hence this is
116
119
// optional.
117
120
stack_bounds : ( uint , uint ) ,
121
+
122
+ stack_guard : uint
118
123
}
119
124
120
125
impl rt:: Runtime for Ops {
@@ -138,6 +143,14 @@ impl rt::Runtime for Ops {
138
143
139
144
fn stack_bounds ( & self ) -> ( uint , uint ) { self . stack_bounds }
140
145
146
+ fn stack_guard ( & self ) -> Option < uint > {
147
+ if self . stack_guard != 0 {
148
+ Some ( self . stack_guard )
149
+ } else {
150
+ None
151
+ }
152
+ }
153
+
141
154
fn can_block ( & self ) -> bool { true }
142
155
143
156
// This function gets a little interesting. There are a few safety and
0 commit comments