Skip to content

Commit f59fcd5

Browse files
committed
core::rt: Store Task as a ~ pointer
1 parent 43c6f32 commit f59fcd5

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/libcore/rt/sched.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,16 @@ pub struct Coroutine {
350350
/// the task is dead
351351
priv saved_context: Context,
352352
/// The heap, GC, unwinding, local storage, logging
353-
task: Task
353+
task: ~Task
354354
}
355355

356356
pub impl Coroutine {
357357
fn new(stack_pool: &mut StackPool, start: ~fn()) -> Coroutine {
358-
Coroutine::with_task(stack_pool, Task::new(), start)
358+
Coroutine::with_task(stack_pool, ~Task::new(), start)
359359
}
360360

361361
fn with_task(stack_pool: &mut StackPool,
362-
task: Task,
362+
task: ~Task,
363363
start: ~fn()) -> Coroutine {
364364
let start = Coroutine::build_start_wrapper(start);
365365
let mut stack = stack_pool.take_segment(MIN_STACK_SIZE);

src/libcore/rt/task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub fn borrow_local_task(f: &fn(&mut Task)) {
155155
do local_sched::borrow |sched| {
156156
match sched.current_task {
157157
Some(~ref mut task) => {
158-
f(&mut task.task)
158+
f(&mut *task.task)
159159
}
160160
None => {
161161
fail!("no local services for schedulers yet")
@@ -167,7 +167,7 @@ pub fn borrow_local_task(f: &fn(&mut Task)) {
167167
pub unsafe fn unsafe_borrow_local_task() -> *mut Task {
168168
match (*local_sched::unsafe_borrow()).current_task {
169169
Some(~ref mut task) => {
170-
let s: *mut Task = &mut task.task;
170+
let s: *mut Task = &mut *task.task;
171171
return s;
172172
}
173173
None => {

src/libcore/rt/test.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn run_in_newsched_task(f: ~fn()) {
2929
do run_in_bare_thread {
3030
let mut sched = ~UvEventLoop::new_scheduler();
3131
let task = ~Coroutine::with_task(&mut sched.stack_pool,
32-
Task::without_unwinding(),
32+
~Task::without_unwinding(),
3333
f.take());
3434
sched.enqueue_task(task);
3535
sched.run();
@@ -42,7 +42,7 @@ pub fn spawntask(f: ~fn()) {
4242

4343
let mut sched = local_sched::take();
4444
let task = ~Coroutine::with_task(&mut sched.stack_pool,
45-
Task::without_unwinding(),
45+
~Task::without_unwinding(),
4646
f);
4747
do sched.switch_running_tasks_and_then(task) |task| {
4848
let task = Cell(task);
@@ -57,7 +57,7 @@ pub fn spawntask_immediately(f: ~fn()) {
5757

5858
let mut sched = local_sched::take();
5959
let task = ~Coroutine::with_task(&mut sched.stack_pool,
60-
Task::without_unwinding(),
60+
~Task::without_unwinding(),
6161
f);
6262
do sched.switch_running_tasks_and_then(task) |task| {
6363
let task = Cell(task);
@@ -73,7 +73,7 @@ pub fn spawntask_later(f: ~fn()) {
7373

7474
let mut sched = local_sched::take();
7575
let task = ~Coroutine::with_task(&mut sched.stack_pool,
76-
Task::without_unwinding(),
76+
~Task::without_unwinding(),
7777
f);
7878

7979
sched.enqueue_task(task);
@@ -90,7 +90,7 @@ pub fn spawntask_random(f: ~fn()) {
9090

9191
let mut sched = local_sched::take();
9292
let task = ~Coroutine::with_task(&mut sched.stack_pool,
93-
Task::without_unwinding(),
93+
~Task::without_unwinding(),
9494
f);
9595

9696
if run_now {
@@ -156,7 +156,7 @@ pub fn spawntask_thread(f: ~fn()) -> Thread {
156156
let thread = do Thread::start {
157157
let mut sched = ~UvEventLoop::new_scheduler();
158158
let task = ~Coroutine::with_task(&mut sched.stack_pool,
159-
Task::without_unwinding(),
159+
~Task::without_unwinding(),
160160
f.take());
161161
sched.enqueue_task(task);
162162
sched.run();

0 commit comments

Comments
 (0)