equal
deleted
inserted
replaced
46 val new_group: group option -> group |
46 val new_group: group option -> group |
47 val worker_task: unit -> task option |
47 val worker_task: unit -> task option |
48 val worker_group: unit -> group option |
48 val worker_group: unit -> group option |
49 val the_worker_group: unit -> group |
49 val the_worker_group: unit -> group |
50 val worker_subgroup: unit -> group |
50 val worker_subgroup: unit -> group |
51 val worker_nest: string -> ('a -> 'b) -> 'a -> 'b |
51 val worker_context: string -> group -> ('a -> 'b) -> 'a -> 'b |
52 val worker_guest: string -> group -> ('a -> 'b) -> 'a -> 'b |
|
53 type 'a future |
52 type 'a future |
54 val task_of: 'a future -> task |
53 val task_of: 'a future -> task |
55 val peek: 'a future -> 'a Exn.result option |
54 val peek: 'a future -> 'a Exn.result option |
56 val is_finished: 'a future -> bool |
55 val is_finished: 'a future -> bool |
57 val ML_statistics: bool Unsynchronized.ref |
56 val ML_statistics: bool Unsynchronized.ref |
108 SOME group => group |
107 SOME group => group |
109 | NONE => raise Fail "Missing worker thread context"); |
108 | NONE => raise Fail "Missing worker thread context"); |
110 |
109 |
111 fun worker_subgroup () = new_group (worker_group ()); |
110 fun worker_subgroup () = new_group (worker_group ()); |
112 |
111 |
113 fun worker_nest name f x = |
112 fun worker_context name group f x = |
114 setmp_worker_task (Task_Queue.new_task (the_worker_group ()) name NONE) f x; |
113 setmp_worker_task (Task_Queue.new_task group name NONE) f x; |
115 |
|
116 fun worker_guest name group f x = |
|
117 if is_some (worker_task ()) then |
|
118 raise Fail "Already running as worker thread" |
|
119 else setmp_worker_task (Task_Queue.new_task group name NONE) f x; |
|
120 |
114 |
121 fun worker_joining e = |
115 fun worker_joining e = |
122 (case worker_task () of |
116 (case worker_task () of |
123 NONE => e () |
117 NONE => e () |
124 | SOME task => Task_Queue.joining task e); |
118 | SOME task => Task_Queue.joining task e); |