File tree Expand file tree Collapse file tree 4 files changed +60
-1
lines changed
branches/auto/src/libcore Expand file tree Collapse file tree 4 files changed +60
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
14
14
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
15
15
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
16
16
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17
- refs/heads/auto: 6773b63671081c722761d3980393642452c08157
17
+ refs/heads/auto: 15ece0c23ef9b2e696ea4e81bf088e37fedc5d01
18
18
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
19
19
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
Original file line number Diff line number Diff line change @@ -160,3 +160,24 @@ fn test_context() {
160
160
sched. run ( ) ;
161
161
}
162
162
}
163
+
164
+ // For setting up tests of the new scheduler
165
+ #[ cfg( test) ]
166
+ pub fn run_in_newsched_task ( f : ~fn ( ) ) {
167
+ use cell:: Cell ;
168
+ use unstable:: run_in_bare_thread;
169
+ use self :: sched:: { Scheduler , Task } ;
170
+ use self :: uvio:: UvEventLoop ;
171
+
172
+ let f = Cell ( Cell ( f) ) ;
173
+
174
+ do run_in_bare_thread {
175
+ let mut sched = ~UvEventLoop : : new_scheduler ( ) ;
176
+ let f = f. take ( ) ;
177
+ let task = ~do Task :: new ( & mut sched. stack_pool ) {
178
+ ( f. take ( ) ) ( ) ;
179
+ } ;
180
+ sched. task_queue . push_back ( task) ;
181
+ sched. run ( ) ;
182
+ }
183
+ }
Original file line number Diff line number Diff line change @@ -1226,3 +1226,12 @@ fn test_spawn_thread_on_demand() {
1226
1226
1227
1227
port. recv ( ) ;
1228
1228
}
1229
+
1230
+ #[ test]
1231
+ fn test_simple_newsched_spawn ( ) {
1232
+ use rt:: run_in_newsched_task;
1233
+
1234
+ do run_in_newsched_task {
1235
+ spawn( ||( ) )
1236
+ }
1237
+ }
Original file line number Diff line number Diff line change @@ -531,6 +531,35 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
531
531
}
532
532
533
533
pub fn spawn_raw ( opts : TaskOpts , f : ~fn ( ) ) {
534
+ use rt:: * ;
535
+
536
+ match context ( ) {
537
+ OldTaskContext => {
538
+ spawn_raw_oldsched ( opts, f)
539
+ }
540
+ TaskContext => {
541
+ spawn_raw_newsched ( opts, f)
542
+ }
543
+ SchedulerContext => {
544
+ fail ! ( ~"can' t spawn from scheduler context")
545
+ }
546
+ GlobalContext => {
547
+ fail!(~" can' t spawn from global context")
548
+ }
549
+ }
550
+ }
551
+
552
+ fn spawn_raw_newsched(opts: TaskOpts, f: ~fn()) {
553
+ use rt::sched::*;
554
+
555
+ // XXX: How to schedule a new task is a policy decision that shouldn't be made here
556
+ let mut sched = Scheduler::take_local();
557
+ let task = ~Task::new(&mut sched.stack_pool, f);
558
+ sched.resume_task_from_running_task_direct(task);
559
+ }
560
+
561
+ fn spawn_raw_oldsched(opts: TaskOpts, f: ~fn()) {
562
+
534
563
let (child_tg, ancestors, is_main) =
535
564
gen_child_taskgroup(opts.linked, opts.supervised);
536
565
You can’t perform that action at this time.
0 commit comments