@@ -30,7 +30,7 @@ export notification;
30
30
export sched_mode;
31
31
export sched_opts;
32
32
export task_opts;
33
- export task_builder :: { } ;
33
+ export builder :: { } ;
34
34
35
35
export default_task_opts;
36
36
export get_opts;
@@ -162,8 +162,8 @@ Provides detailed control over the properties and behavior of new tasks.
162
162
// when you try to reuse the builder to spawn a new task. We'll just
163
163
// sidestep that whole issue by making builder's uncopyable and making
164
164
// the run function move them in.
165
- enum task_builder {
166
- task_builder_ ( {
165
+ enum builder {
166
+ builder_ ( {
167
167
mut opts : task_opts ,
168
168
mut gen_body : fn @( +fn ~( ) ) -> fn ~( ) ,
169
169
can_not_copy : option < comm:: port < ( ) > >
@@ -188,27 +188,27 @@ fn default_task_opts() -> task_opts {
188
188
}
189
189
}
190
190
191
- fn task_builder ( ) -> task_builder {
192
- #[ doc = "Construct a task_builder " ] ;
191
+ fn builder ( ) -> builder {
192
+ #[ doc = "Construct a builder " ] ;
193
193
194
194
let body_identity = fn@( +body : fn ~( ) ) -> fn ~( ) { body } ;
195
195
196
- task_builder_ ( {
196
+ builder_ ( {
197
197
mut opts: default_task_opts ( ) ,
198
198
mut gen_body: body_identity,
199
199
can_not_copy: none
200
200
} )
201
201
}
202
202
203
- fn get_opts ( builder : task_builder ) -> task_opts {
204
- #[ doc = "Get the task_opts associated with a task_builder " ] ;
203
+ fn get_opts ( builder : builder ) -> task_opts {
204
+ #[ doc = "Get the task_opts associated with a builder " ] ;
205
205
206
206
builder. opts
207
207
}
208
208
209
- fn set_opts ( builder : task_builder , opts : task_opts ) {
209
+ fn set_opts ( builder : builder , opts : task_opts ) {
210
210
#[ doc = "
211
- Set the task_opts associated with a task_builder
211
+ Set the task_opts associated with a builder
212
212
213
213
To update a single option use a pattern like the following:
214
214
@@ -221,7 +221,7 @@ fn set_opts(builder: task_builder, opts: task_opts) {
221
221
builder. opts = opts;
222
222
}
223
223
224
- fn add_wrapper ( builder : task_builder , gen_body : fn @( +fn ~( ) ) -> fn ~( ) ) {
224
+ fn add_wrapper ( builder : builder , gen_body : fn @( +fn ~( ) ) -> fn ~( ) ) {
225
225
#[ doc = "
226
226
Add a wrapper to the body of the spawned task.
227
227
@@ -241,7 +241,7 @@ fn add_wrapper(builder: task_builder, gen_body: fn@(+fn~()) -> fn~()) {
241
241
} ;
242
242
}
243
243
244
- fn run ( -builder : task_builder , +f : fn ~( ) ) {
244
+ fn run ( -builder : builder , +f : fn ~( ) ) {
245
245
#[ doc = "
246
246
Creates and exucutes a new child task
247
247
@@ -262,7 +262,7 @@ fn run(-builder: task_builder, +f: fn~()) {
262
262
263
263
/* Builder convenience functions */
264
264
265
- fn future_result ( builder : task_builder ) -> future:: future < task_result > {
265
+ fn future_result ( builder : builder ) -> future:: future < task_result > {
266
266
#[ doc = "
267
267
Get a future representing the exit status of the task.
268
268
@@ -295,7 +295,7 @@ fn future_result(builder: task_builder) -> future::future<task_result> {
295
295
}
296
296
}
297
297
298
- fn future_task ( builder : task_builder ) -> future:: future < task > {
298
+ fn future_task ( builder : builder ) -> future:: future < task > {
299
299
#[ doc = "Get a future representing the handle to the new task" ] ;
300
300
301
301
let mut po = comm:: port ( ) ;
@@ -309,7 +309,7 @@ fn future_task(builder: task_builder) -> future::future<task> {
309
309
future:: from_port ( po)
310
310
}
311
311
312
- fn unsupervise ( builder : task_builder ) {
312
+ fn unsupervise ( builder : builder ) {
313
313
#[ doc = "Configures the new task to not propagate failure to its parent" ] ;
314
314
315
315
set_opts ( builder, {
@@ -318,7 +318,7 @@ fn unsupervise(builder: task_builder) {
318
318
} ) ;
319
319
}
320
320
321
- fn run_listener < A : send > ( -builder : task_builder ,
321
+ fn run_listener < A : send > ( -builder : builder ,
322
322
+f : fn ~( comm:: port < A > ) ) -> comm:: chan < A > {
323
323
#[ doc = "
324
324
Runs a new task while providing a channel from the parent to the child
@@ -355,10 +355,10 @@ fn spawn(+f: fn~()) {
355
355
Sets up a new task with its own call stack and schedules it to run
356
356
the provided unique closure.
357
357
358
- This function is equivalent to `run(new_task_builder (), f)`.
358
+ This function is equivalent to `run(new_builder (), f)`.
359
359
" ] ;
360
360
361
- run ( task_builder ( ) , f) ;
361
+ run ( builder ( ) , f) ;
362
362
}
363
363
364
364
fn spawn_listener < A : send > ( +f : fn ~( comm:: port < A > ) ) -> comm:: chan < A > {
@@ -384,10 +384,10 @@ fn spawn_listener<A:send>(+f: fn~(comm::port<A>)) -> comm::chan<A> {
384
384
};
385
385
// Likewise, the parent has both a 'po' and 'ch'
386
386
387
- This function is equivalent to `run_listener(new_task_builder (), f)`.
387
+ This function is equivalent to `run_listener(new_builder (), f)`.
388
388
" ] ;
389
389
390
- run_listener ( task_builder ( ) , f)
390
+ run_listener ( builder ( ) , f)
391
391
}
392
392
393
393
fn spawn_sched ( mode : sched_mode , +f : fn ~( ) ) {
@@ -404,7 +404,7 @@ fn spawn_sched(mode: sched_mode, +f: fn~()) {
404
404
greater than zero.
405
405
" ] ;
406
406
407
- let mut builder = task_builder ( ) ;
407
+ let mut builder = builder ( ) ;
408
408
set_opts ( builder, {
409
409
sched: some ( {
410
410
mode: mode,
@@ -429,7 +429,7 @@ fn try<T:send>(+f: fn~() -> T) -> result<T,()> {
429
429
430
430
let po = comm:: port ( ) ;
431
431
let ch = comm:: chan ( po) ;
432
- let mut builder = task_builder ( ) ;
432
+ let mut builder = builder ( ) ;
433
433
unsupervise ( builder) ;
434
434
let result = future_result ( builder) ;
435
435
run ( builder) { ||
@@ -626,8 +626,8 @@ fn test_spawn_raw_notify() {
626
626
fn test_run_basic ( ) {
627
627
let po = comm:: port ( ) ;
628
628
let ch = comm:: chan ( po) ;
629
- let builder = task_builder ( ) ;
630
- run ( builder ) { ||
629
+ let buildr = builder ( ) ;
630
+ run ( buildr ) { ||
631
631
comm:: send ( ch, ( ) ) ;
632
632
}
633
633
comm:: recv ( po) ;
@@ -637,39 +637,39 @@ fn test_run_basic() {
637
637
fn test_add_wrapper ( ) {
638
638
let po = comm:: port ( ) ;
639
639
let ch = comm:: chan ( po) ;
640
- let builder = task_builder ( ) ;
641
- add_wrapper ( builder ) { |body|
640
+ let buildr = builder ( ) ;
641
+ add_wrapper ( buildr ) { |body|
642
642
fn ~( ) {
643
643
body ( ) ;
644
644
comm:: send ( ch, ( ) ) ;
645
645
}
646
646
}
647
- run ( builder ) { ||}
647
+ run ( buildr ) { ||}
648
648
comm:: recv ( po) ;
649
649
}
650
650
651
651
#[ test]
652
652
#[ ignore( cfg( target_os = "win32" ) ) ]
653
653
fn test_future_result ( ) {
654
- let builder = task_builder ( ) ;
655
- let result = future_result ( builder ) ;
656
- run ( builder ) { ||}
654
+ let buildr = builder ( ) ;
655
+ let result = future_result ( buildr ) ;
656
+ run ( buildr ) { ||}
657
657
assert future:: get ( result) == success;
658
658
659
- let builder = task_builder ( ) ;
660
- let result = future_result ( builder ) ;
661
- unsupervise ( builder ) ;
662
- run ( builder ) { || fail }
659
+ let buildr = builder ( ) ;
660
+ let result = future_result ( buildr ) ;
661
+ unsupervise ( buildr ) ;
662
+ run ( buildr ) { || fail }
663
663
assert future:: get ( result) == failure;
664
664
}
665
665
666
666
#[ test]
667
667
fn test_future_task ( ) {
668
668
let po = comm:: port ( ) ;
669
669
let ch = comm:: chan ( po) ;
670
- let builder = task_builder ( ) ;
671
- let task1 = future_task ( builder ) ;
672
- run ( builder ) { || comm:: send ( ch, get_task ( ) ) }
670
+ let buildr = builder ( ) ;
671
+ let task1 = future_task ( buildr ) ;
672
+ run ( buildr ) { || comm:: send ( ch, get_task ( ) ) }
673
673
assert future:: get ( task1) == comm:: recv ( po) ;
674
674
}
675
675
@@ -863,8 +863,8 @@ fn test_avoid_copying_the_body_spawn_listener() {
863
863
#[ test]
864
864
fn test_avoid_copying_the_body_run ( ) {
865
865
avoid_copying_the_body { |f|
866
- let builder = task_builder ( ) ;
867
- run ( builder ) { ||
866
+ let buildr = builder ( ) ;
867
+ run ( buildr ) { ||
868
868
f ( ) ;
869
869
}
870
870
}
@@ -873,8 +873,8 @@ fn test_avoid_copying_the_body_run() {
873
873
#[ test]
874
874
fn test_avoid_copying_the_body_run_listener ( ) {
875
875
avoid_copying_the_body { |f|
876
- let builder = task_builder ( ) ;
877
- run_listener ( builder , fn~[ move f] ( _po: comm:: port<int>) {
876
+ let buildr = builder ( ) ;
877
+ run_listener ( buildr , fn~[ move f] ( _po: comm:: port<int>) {
878
878
f ( ) ;
879
879
} ) ;
880
880
}
@@ -892,9 +892,9 @@ fn test_avoid_copying_the_body_try() {
892
892
#[ test]
893
893
fn test_avoid_copying_the_body_future_task ( ) {
894
894
avoid_copying_the_body { |f|
895
- let builder = task_builder ( ) ;
896
- future_task ( builder ) ;
897
- run ( builder ) { ||
895
+ let buildr = builder ( ) ;
896
+ future_task ( buildr ) ;
897
+ run ( buildr ) { ||
898
898
f ( ) ;
899
899
}
900
900
}
@@ -903,29 +903,29 @@ fn test_avoid_copying_the_body_future_task() {
903
903
#[ test]
904
904
fn test_avoid_copying_the_body_unsupervise ( ) {
905
905
avoid_copying_the_body { |f|
906
- let builder = task_builder ( ) ;
907
- unsupervise ( builder ) ;
908
- run ( builder ) { ||
906
+ let buildr = builder ( ) ;
907
+ unsupervise ( buildr ) ;
908
+ run ( buildr ) { ||
909
909
f ( ) ;
910
910
}
911
911
}
912
912
}
913
913
914
914
#[ test]
915
915
fn test_osmain ( ) {
916
- let builder = task_builder ( ) ;
916
+ let buildr = builder ( ) ;
917
917
let opts = {
918
918
sched: some ( {
919
919
mode: osmain,
920
920
native_stack_size: none
921
921
} )
922
- with get_opts ( builder )
922
+ with get_opts ( buildr )
923
923
} ;
924
- set_opts ( builder , opts) ;
924
+ set_opts ( buildr , opts) ;
925
925
926
926
let po = comm:: port ( ) ;
927
927
let ch = comm:: chan ( po) ;
928
- run ( builder ) { ||
928
+ run ( buildr ) { ||
929
929
comm:: send ( ch, ( ) ) ;
930
930
}
931
931
comm:: recv ( po) ;
0 commit comments