// A helper to build a new task using the dynamically found
// scheduler and task. Only works in GreenTask context.
// A helper to build a new task using the dynamically found
// scheduler and task. Only works in GreenTask context.
let f = Cell::new(f);
let home = Cell::new(home);
do Local::borrow::<Task, ~Task> |running_task| {
let mut sched = running_task.sched.take_unwrap();
let new_task = ~running_task.new_child_homed(&mut sched.stack_pool,
let f = Cell::new(f);
let home = Cell::new(home);
do Local::borrow::<Task, ~Task> |running_task| {
let mut sched = running_task.sched.take_unwrap();
let new_task = ~running_task.new_child_homed(&mut sched.stack_pool,
- pub fn build_child(f: ~fn()) -> ~Task {
- Task::build_homed_child(f, AnySched)
+ pub fn build_child(stack_size: Option<uint>, f: ~fn()) -> ~Task {
+ Task::build_homed_child(stack_size, f, AnySched)
let f = Cell::new(f);
let home = Cell::new(home);
do Local::borrow::<Task, ~Task> |running_task| {
let mut sched = running_task.sched.take_unwrap();
let new_task = ~Task::new_root_homed(&mut sched.stack_pool,
let f = Cell::new(f);
let home = Cell::new(home);
do Local::borrow::<Task, ~Task> |running_task| {
let mut sched = running_task.sched.take_unwrap();
let new_task = ~Task::new_root_homed(&mut sched.stack_pool,
- pub fn build_root(f: ~fn()) -> ~Task {
- Task::build_homed_root(f, AnySched)
+ pub fn build_root(stack_size: Option<uint>, f: ~fn()) -> ~Task {
+ Task::build_homed_root(stack_size, f, AnySched)
- Task::new_root_homed(stack_pool, AnySched, start)
+ Task::new_root_homed(stack_pool, stack_size, AnySched, start)
}
pub fn new_child(&mut self,
stack_pool: &mut StackPool,
}
pub fn new_child(&mut self,
stack_pool: &mut StackPool,
- self.new_child_homed(stack_pool, AnySched, start)
+ self.new_child_homed(stack_pool, stack_size, AnySched, start)
- coroutine: Some(Coroutine::new(stack_pool, start)),
+ coroutine: Some(Coroutine::new(stack_pool, stack_size, start)),
pub fn new_child_homed(&mut self,
stack_pool: &mut StackPool,
pub fn new_child_homed(&mut self,
stack_pool: &mut StackPool,
- coroutine: Some(Coroutine::new(stack_pool, start)),
+ coroutine: Some(Coroutine::new(stack_pool, stack_size, start)),
- pub fn new(stack_pool: &mut StackPool, start: ~fn()) -> Coroutine {
- let stack_size = env::min_stack();
+ pub fn new(stack_pool: &mut StackPool, stack_size: Option<uint>, start: ~fn()) -> Coroutine {
+ let stack_size = match stack_size {
+ Some(size) => size,
+ None => env::min_stack()
+ };
let start = Coroutine::build_start_wrapper(start);
let mut stack = stack_pool.take_segment(stack_size);
let initial_context = Context::new(start, &mut stack);
let start = Coroutine::build_start_wrapper(start);
let mut stack = stack_pool.take_segment(stack_size);
let initial_context = Context::new(start, &mut stack);