@@ -32,54 +32,11 @@ use result::Result;
32
32
use pipes:: { stream, Chan , Port } ;
33
33
use local_data_priv:: { local_get, local_set} ;
34
34
35
- export Task ;
36
- export TaskResult ;
37
- export Notification ;
38
- export SchedMode ;
39
- export SchedOpts ;
40
- export TaskOpts ;
41
- export TaskBuilder ;
42
-
43
- export task;
44
- export default_task_opts;
45
- export get_opts;
46
- export set_opts;
47
- export set_sched_mode;
48
- export add_wrapper;
49
- export run;
50
-
51
- export future_result;
52
- export run_listener;
53
- export run_with;
54
-
55
- export spawn;
56
- export spawn_unlinked;
57
- export spawn_supervised;
58
- export spawn_with;
59
- export spawn_listener;
60
- export spawn_conversation;
61
- export spawn_sched;
62
- export try;
63
-
64
- export yield;
65
- export failing;
66
- export get_task;
67
- export unkillable, rekillable;
68
- export atomically;
69
-
70
- export local_data;
71
-
72
- export SingleThreaded ;
73
- export ThreadPerCore ;
74
- export ThreadPerTask ;
75
- export ManualThreads ;
76
- export PlatformThread ;
77
-
78
35
use rt:: task_id;
79
36
use rt:: rust_task;
80
37
81
38
/// A handle to a task
82
- enum Task {
39
+ pub enum Task {
83
40
TaskHandle ( task_id )
84
41
}
85
42
@@ -99,7 +56,7 @@ impl Task : cmp::Eq {
99
56
* If you wish for this result's delivery to block until all linked and/or
100
57
* children tasks complete, recommend using a result future.
101
58
*/
102
- enum TaskResult {
59
+ pub enum TaskResult {
103
60
Success ,
104
61
Failure ,
105
62
}
@@ -115,7 +72,7 @@ impl TaskResult : Eq {
115
72
}
116
73
117
74
/// A message type for notifying of task lifecycle events
118
- enum Notification {
75
+ pub enum Notification {
119
76
/// Sent when a task exits with the task handle and result
120
77
Exit ( Task , TaskResult )
121
78
}
@@ -134,7 +91,7 @@ impl Notification : cmp::Eq {
134
91
}
135
92
136
93
/// Scheduler modes
137
- enum SchedMode {
94
+ pub enum SchedMode {
138
95
/// All tasks run in the same OS thread
139
96
SingleThreaded ,
140
97
/// Tasks are distributed among available CPUs
@@ -207,7 +164,7 @@ impl SchedMode : cmp::Eq {
207
164
* default these foreign stacks have unspecified size, but with this
208
165
* option their size can be precisely specified.
209
166
*/
210
- type SchedOpts = {
167
+ pub type SchedOpts = {
211
168
mode : SchedMode ,
212
169
foreign_stack_size : Option < uint >
213
170
} ;
@@ -239,7 +196,7 @@ type SchedOpts = {
239
196
* into foreign code that blocks. Without doing so in a different
240
197
* scheduler other tasks will be impeded or even blocked indefinitely.
241
198
*/
242
- type TaskOpts = {
199
+ pub type TaskOpts = {
243
200
linked : bool ,
244
201
supervised : bool ,
245
202
mut notify_chan : Option < Chan < Notification > > ,
@@ -260,7 +217,7 @@ type TaskOpts = {
260
217
// the run function move them in.
261
218
262
219
// FIXME (#2585): Replace the 'consumed' bit with move mode on self
263
- enum TaskBuilder = {
220
+ pub enum TaskBuilder = {
264
221
opts: TaskOpts ,
265
222
gen_body: fn @( +v : fn ~( ) ) -> fn ~( ) ,
266
223
can_not_copy : Option < util:: NonCopyable > ,
@@ -272,7 +229,7 @@ enum TaskBuilder = {
272
229
* configuration methods can be chained.
273
230
* For example, task().unlinked().spawn is equivalent to spawn_unlinked.
274
231
*/
275
- fn task ( ) -> TaskBuilder {
232
+ pub fn task ( ) -> TaskBuilder {
276
233
TaskBuilder ( {
277
234
opts: default_task_opts ( ) ,
278
235
gen_body: |body| move body, // Identity function
@@ -580,7 +537,7 @@ impl TaskBuilder {
580
537
581
538
/* Task construction */
582
539
583
- fn default_task_opts() -> TaskOpts {
540
+ pub fn default_task_opts() -> TaskOpts {
584
541
/*!
585
542
* The default task options
586
543
*
@@ -598,7 +555,7 @@ fn default_task_opts() -> TaskOpts {
598
555
599
556
/* Spawn convenience functions */
600
557
601
- fn spawn(+f: fn~()) {
558
+ pub fn spawn(+f: fn~()) {
602
559
/*!
603
560
* Creates and executes a new child task
604
561
*
@@ -611,7 +568,7 @@ fn spawn(+f: fn~()) {
611
568
task().spawn(move f)
612
569
}
613
570
614
- fn spawn_unlinked(+f: fn~()) {
571
+ pub fn spawn_unlinked(+f: fn~()) {
615
572
/*!
616
573
* Creates a child task unlinked from the current one. If either this
617
574
* task or the child task fails, the other will not be killed.
@@ -620,7 +577,7 @@ fn spawn_unlinked(+f: fn~()) {
620
577
task().unlinked().spawn(move f)
621
578
}
622
579
623
- fn spawn_supervised(+f: fn~()) {
580
+ pub fn spawn_supervised(+f: fn~()) {
624
581
/*!
625
582
* Creates a child task unlinked from the current one. If either this
626
583
* task or the child task fails, the other will not be killed.
@@ -629,7 +586,7 @@ fn spawn_supervised(+f: fn~()) {
629
586
task().supervised().spawn(move f)
630
587
}
631
588
632
- fn spawn_with<A:Send>(+arg: A, +f: fn~(+v: A)) {
589
+ pub fn spawn_with<A:Send>(+arg: A, +f: fn~(+v: A)) {
633
590
/*!
634
591
* Runs a task, while transfering ownership of one argument to the
635
592
* child.
@@ -643,7 +600,7 @@ fn spawn_with<A:Send>(+arg: A, +f: fn~(+v: A)) {
643
600
task().spawn_with(move arg, move f)
644
601
}
645
602
646
- fn spawn_listener<A:Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
603
+ pub fn spawn_listener<A:Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
647
604
/*!
648
605
* Runs a new task while providing a channel from the parent to the child
649
606
*
@@ -653,7 +610,7 @@ fn spawn_listener<A:Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
653
610
task().spawn_listener(move f)
654
611
}
655
612
656
- fn spawn_conversation<A: Send, B: Send>
613
+ pub fn spawn_conversation<A: Send, B: Send>
657
614
(+f: fn~(comm::Port<A>, comm::Chan<B>))
658
615
-> (comm::Port<B>, comm::Chan<A>) {
659
616
/*!
@@ -665,7 +622,7 @@ fn spawn_conversation<A: Send, B: Send>
665
622
task().spawn_conversation(move f)
666
623
}
667
624
668
- fn spawn_sched(mode: SchedMode, +f: fn~()) {
625
+ pub fn spawn_sched(mode: SchedMode, +f: fn~()) {
669
626
/*!
670
627
* Creates a new scheduler and executes a task on it
671
628
*
@@ -682,7 +639,7 @@ fn spawn_sched(mode: SchedMode, +f: fn~()) {
682
639
task().sched_mode(mode).spawn(move f)
683
640
}
684
641
685
- fn try<T:Send>(+f: fn~() -> T) -> Result<T,()> {
642
+ pub fn try<T:Send>(+f: fn~() -> T) -> Result<T,()> {
686
643
/*!
687
644
* Execute a function in another task and return either the return value
688
645
* of the function or result::err.
@@ -696,7 +653,7 @@ fn try<T:Send>(+f: fn~() -> T) -> Result<T,()> {
696
653
697
654
/* Lifecycle functions */
698
655
699
- fn yield() {
656
+ pub fn yield() {
700
657
//! Yield control to the task scheduler
701
658
702
659
let task_ = rt::rust_get_task();
@@ -706,13 +663,13 @@ fn yield() {
706
663
}
707
664
}
708
665
709
- fn failing( ) -> bool {
666
+ pub fn failing( ) -> bool {
710
667
//! True if the running task has failed
711
668
712
669
rt:: rust_task_is_unwinding( rt:: rust_get_task( ) )
713
670
}
714
671
715
- fn get_task( ) -> Task {
672
+ pub fn get_task( ) -> Task {
716
673
//! Get a handle to the running task
717
674
718
675
TaskHandle ( rt:: get_task_id( ) )
@@ -733,7 +690,7 @@ fn get_task() -> Task {
733
690
* }
734
691
* ~~~
735
692
*/
736
- unsafe fn unkillable < U > ( f: fn ( ) -> U ) -> U {
693
+ pub unsafe fn unkillable < U > ( f: fn ( ) -> U ) -> U {
737
694
struct AllowFailure {
738
695
t : * rust_task,
739
696
drop { rt : : rust_task_allow_kill( self . t) ; }
@@ -752,7 +709,7 @@ unsafe fn unkillable<U>(f: fn() -> U) -> U {
752
709
}
753
710
754
711
/// The inverse of unkillable. Only ever to be used nested in unkillable().
755
- unsafe fn rekillable < U > ( f: fn ( ) -> U ) -> U {
712
+ pub unsafe fn rekillable < U > ( f: fn ( ) -> U ) -> U {
756
713
struct DisallowFailure {
757
714
t : * rust_task,
758
715
drop { rt : : rust_task_inhibit_kill( self . t) ; }
@@ -774,7 +731,7 @@ unsafe fn rekillable<U>(f: fn() -> U) -> U {
774
731
* A stronger version of unkillable that also inhibits scheduling operations.
775
732
* For use with exclusive ARCs, which use pthread mutexes directly.
776
733
*/
777
- unsafe fn atomically < U > ( f: fn ( ) -> U ) -> U {
734
+ pub unsafe fn atomically < U > ( f: fn ( ) -> U ) -> U {
778
735
struct DeferInterrupts {
779
736
t : * rust_task,
780
737
drop {
@@ -1102,7 +1059,6 @@ fn test_spawn_sched_childs_on_same_sched() {
1102
1059
#[ nolink]
1103
1060
#[ cfg( test) ]
1104
1061
extern mod testrt {
1105
- #[ legacy_exports] ;
1106
1062
fn rust_dbg_lock_create( ) -> * libc : : c_void;
1107
1063
fn rust_dbg_lock_destroy( lock: * libc:: c_void) ;
1108
1064
fn rust_dbg_lock_lock( lock: * libc:: c_void) ;
0 commit comments