195195// NB this does *not* include globs, please keep it that way.
196196#![ feature( macro_rules, phase) ]
197197#![ allow( visible_private_types) ]
198+ #![ deny( deprecated_owned_vector) ]
198199
199200#[ cfg( test) ] #[ phase( syntax, link) ] extern crate log;
200201#[ cfg( test) ] extern crate rustuv;
@@ -209,7 +210,6 @@ use std::rt;
209210use std:: sync:: atomics:: { SeqCst , AtomicUint , INIT_ATOMIC_UINT } ;
210211use std:: sync:: deque;
211212use std:: task:: TaskOpts ;
212- use std:: slice;
213213use std:: sync:: arc:: UnsafeArc ;
214214
215215use sched:: { Shutdown , Scheduler , SchedHandle , TaskFromFriend , NewNeighbor } ;
@@ -318,9 +318,9 @@ impl PoolConfig {
318318/// used to keep the pool alive and also reap the status from the pool.
319319pub struct SchedPool {
320320 id : uint ,
321- threads : ~ [ Thread < ( ) > ] ,
322- handles : ~ [ SchedHandle ] ,
323- stealers : ~ [ deque:: Stealer < ~task:: GreenTask > ] ,
321+ threads : Vec < Thread < ( ) > > ,
322+ handles : Vec < SchedHandle > ,
323+ stealers : Vec < deque:: Stealer < ~task:: GreenTask > > ,
324324 next_friend : uint ,
325325 stack_pool : StackPool ,
326326 deque_pool : deque:: BufferPool < ~task:: GreenTask > ,
@@ -356,9 +356,9 @@ impl SchedPool {
356356 // The pool of schedulers that will be returned from this function
357357 let ( p, state) = TaskState :: new ( ) ;
358358 let mut pool = SchedPool {
359- threads : ~ [ ] ,
360- handles : ~ [ ] ,
361- stealers : ~ [ ] ,
359+ threads : vec ! [ ] ,
360+ handles : vec ! [ ] ,
361+ stealers : vec ! [ ] ,
362362 id : unsafe { POOL_ID . fetch_add ( 1 , SeqCst ) } ,
363363 sleepers : SleeperList :: new ( ) ,
364364 stack_pool : StackPool :: new ( ) ,
@@ -371,8 +371,14 @@ impl SchedPool {
371371
372372 // Create a work queue for each scheduler, ntimes. Create an extra
373373 // for the main thread if that flag is set. We won't steal from it.
374- let arr = slice:: from_fn ( nscheds, |_| pool. deque_pool . deque ( ) ) ;
375- let ( workers, stealers) = slice:: unzip ( arr. move_iter ( ) ) ;
374+ let mut workers = Vec :: with_capacity ( nscheds) ;
375+ let mut stealers = Vec :: with_capacity ( nscheds) ;
376+
377+ for _ in range ( 0 , nscheds) {
378+ let ( w, s) = pool. deque_pool . deque ( ) ;
379+ workers. push ( w) ;
380+ stealers. push ( s) ;
381+ }
376382 pool. stealers = stealers;
377383
378384 // Now that we've got all our work queues, create one scheduler per
@@ -420,7 +426,7 @@ impl SchedPool {
420426 }
421427
422428 // Jettison the task away!
423- self . handles [ idx] . send ( TaskFromFriend ( task) ) ;
429+ self . handles . get_mut ( idx) . send ( TaskFromFriend ( task) ) ;
424430 }
425431
426432 /// Spawns a new scheduler into this M:N pool. A handle is returned to the
@@ -466,7 +472,7 @@ impl SchedPool {
466472 /// This only waits for all tasks in *this pool* of schedulers to exit, any
467473 /// native tasks or extern pools will not be waited on
468474 pub fn shutdown ( mut self ) {
469- self . stealers = ~ [ ] ;
475+ self . stealers = vec ! [ ] ;
470476
471477 // Wait for everyone to exit. We may have reached a 0-task count
472478 // multiple times in the past, meaning there could be several buffered
@@ -478,10 +484,10 @@ impl SchedPool {
478484 }
479485
480486 // Now that everyone's gone, tell everything to shut down.
481- for mut handle in replace ( & mut self . handles , ~ [ ] ) . move_iter ( ) {
487+ for mut handle in replace ( & mut self . handles , vec ! [ ] ) . move_iter ( ) {
482488 handle. send ( Shutdown ) ;
483489 }
484- for thread in replace ( & mut self . threads , ~ [ ] ) . move_iter ( ) {
490+ for thread in replace ( & mut self . threads , vec ! [ ] ) . move_iter ( ) {
485491 thread. join ( ) ;
486492 }
487493 }
0 commit comments