Skip to content

Commit 75a913f

Browse files
committed
Merge remote-tracking branch 'toddaaro/niots'
Conflicts: src/libstd/rt/sched.rs
2 parents 6fd15ff + 0607178 commit 75a913f

File tree

12 files changed

+386
-551
lines changed

12 files changed

+386
-551
lines changed

src/libstd/rt/comm.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use cast;
2020
use util;
2121
use ops::Drop;
2222
use kinds::Owned;
23-
use rt::sched::{Scheduler, Coroutine};
23+
use rt::sched::{Scheduler};
24+
use rt::task::Task;
2425
use rt::local::Local;
2526
use unstable::atomics::{AtomicUint, AtomicOption, SeqCst};
2627
use unstable::sync::UnsafeAtomicRcBox;
@@ -136,7 +137,7 @@ impl<T> ChanOne<T> {
136137
}
137138
task_as_state => {
138139
// Port is blocked. Wake it up.
139-
let recvr: ~Coroutine = cast::transmute(task_as_state);
140+
let recvr: ~Task = cast::transmute(task_as_state);
140141
let mut sched = Local::take::<Scheduler>();
141142
rtdebug!("rendezvous send");
142143
sched.metrics.rendezvous_sends += 1;
@@ -192,7 +193,7 @@ impl<T> PortOne<T> {
192193
// NB: We have to drop back into the scheduler event loop here
193194
// instead of switching immediately back or we could end up
194195
// triggering infinite recursion on the scheduler's stack.
195-
let task: ~Coroutine = cast::transmute(task_as_state);
196+
let task: ~Task = cast::transmute(task_as_state);
196197
sched.enqueue_task(task);
197198
}
198199
_ => util::unreachable()
@@ -257,7 +258,7 @@ impl<T> Drop for ChanOneHack<T> {
257258
task_as_state => {
258259
// The port is blocked waiting for a message we will never send. Wake it.
259260
assert!((*this.packet()).payload.is_none());
260-
let recvr: ~Coroutine = cast::transmute(task_as_state);
261+
let recvr: ~Task = cast::transmute(task_as_state);
261262
let sched = Local::take::<Scheduler>();
262263
sched.schedule_task(recvr);
263264
}
@@ -554,6 +555,8 @@ mod test {
554555
{ let _c = chan; }
555556
port.recv();
556557
};
558+
// What is our res?
559+
rtdebug!("res is: %?", res.is_err());
557560
assert!(res.is_err());
558561
}
559562
}
@@ -905,4 +908,5 @@ mod test {
905908
}
906909
}
907910
}
911+
908912
}

src/libstd/rt/join_latch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,3 +643,4 @@ mod test {
643643
}
644644
}
645645
}
646+

src/libstd/rt/local.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rt::sched::Scheduler;
1313
use rt::task::Task;
1414
use rt::local_ptr;
1515
use rt::rtio::{EventLoop, IoFactoryObject};
16+
//use borrow::to_uint;
1617

1718
pub trait Local {
1819
fn put(value: ~Self);
@@ -32,6 +33,7 @@ impl Local for Scheduler {
3233
let res_ptr: *mut Option<T> = &mut res;
3334
unsafe {
3435
do local_ptr::borrow |sched| {
36+
// rtdebug!("successfully unsafe borrowed sched pointer");
3537
let result = f(sched);
3638
*res_ptr = Some(result);
3739
}
@@ -51,9 +53,12 @@ impl Local for Task {
5153
fn exists() -> bool { rtabort!("unimpl") }
5254
fn borrow<T>(f: &fn(&mut Task) -> T) -> T {
5355
do Local::borrow::<Scheduler, T> |sched| {
56+
// rtdebug!("sched about to grab current_task");
5457
match sched.current_task {
5558
Some(~ref mut task) => {
56-
f(&mut *task.task)
59+
// rtdebug!("current task pointer: %x", to_uint(task));
60+
// rtdebug!("current task heap pointer: %x", to_uint(&task.heap));
61+
f(task)
5762
}
5863
None => {
5964
rtabort!("no scheduler")
@@ -64,7 +69,7 @@ impl Local for Task {
6469
unsafe fn unsafe_borrow() -> *mut Task {
6570
match (*Local::unsafe_borrow::<Scheduler>()).current_task {
6671
Some(~ref mut task) => {
67-
let s: *mut Task = &mut *task.task;
72+
let s: *mut Task = &mut *task;
6873
return s;
6974
}
7075
None => {

src/libstd/rt/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use iter::Times;
6767
use iterator::IteratorUtil;
6868
use option::Some;
6969
use ptr::RawPtr;
70-
use rt::sched::{Scheduler, Coroutine, Shutdown};
70+
use rt::sched::{Scheduler, Shutdown};
7171
use rt::sleeper_list::SleeperList;
7272
use rt::task::Task;
7373
use rt::thread::Thread;
@@ -267,10 +267,10 @@ pub fn run(main: ~fn()) -> int {
267267
};
268268

269269
// Create and enqueue the main task.
270-
let mut new_task = ~Task::new_root();
271-
new_task.on_exit = Some(on_exit);
272-
let main_task = ~Coroutine::with_task(&mut scheds[0].stack_pool,
273-
new_task, main);
270+
let main_cell = Cell::new(main);
271+
let mut main_task = ~Task::new_root(&mut scheds[0].stack_pool,
272+
main_cell.take());
273+
main_task.on_exit = Some(on_exit);
274274
scheds[0].enqueue_task(main_task);
275275

276276
// Run each scheduler in a thread.
@@ -347,15 +347,15 @@ pub fn context() -> RuntimeContext {
347347
#[test]
348348
fn test_context() {
349349
use unstable::run_in_bare_thread;
350-
use self::sched::{Scheduler, Coroutine};
350+
use self::sched::{Scheduler};
351351
use rt::local::Local;
352352
use rt::test::new_test_uv_sched;
353353

354354
assert_eq!(context(), OldTaskContext);
355355
do run_in_bare_thread {
356356
assert_eq!(context(), GlobalContext);
357357
let mut sched = ~new_test_uv_sched();
358-
let task = ~do Coroutine::new_root(&mut sched.stack_pool) {
358+
let task = ~do Task::new_root(&mut sched.stack_pool) {
359359
assert_eq!(context(), TaskContext);
360360
let sched = Local::take::<Scheduler>();
361361
do sched.deschedule_running_task_and_then() |sched, task| {

0 commit comments

Comments
 (0)