File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ pub fn spawntask_try(f: ~fn()) -> Result<(), ()> {
293
293
if exit_status { Ok ( ( ) ) } else { Err ( ( ) ) }
294
294
}
295
295
296
- // Spawn a new task in a new scheduler and return a thread handle.
296
+ /// Spawn a new task in a new scheduler and return a thread handle.
297
297
pub fn spawntask_thread( f: ~fn ( ) ) -> Thread {
298
298
use rt:: sched : : * ;
299
299
@@ -317,6 +317,16 @@ pub fn spawntask_thread(f: ~fn()) -> Thread {
317
317
return thread;
318
318
}
319
319
320
+ /// Get a ~Task for testing purposes other than actually scheduling it.
321
+ pub fn with_test_task( blk: ~fn ( ~Task ) -> ~Task ) {
322
+ do run_in_bare_thread {
323
+ let mut sched = ~new_test_uv_sched( ) ;
324
+ let task = blk( ~Task :: new_root( & mut sched. stack_pool, ||{ } ) ) ;
325
+ sched. enqueue_task( task) ;
326
+ sched. run( ) ;
327
+ }
328
+ }
329
+
320
330
321
331
/// Get a port number, starting at 9600, for use in tests
322
332
pub fn next_test_port( ) -> u16 {
You can’t perform that action at this time.
0 commit comments