equal
deleted
inserted
replaced
21 val trace: int ref |
21 val trace: int ref |
22 val tracing: int -> (unit -> string) -> unit |
22 val tracing: int -> (unit -> string) -> unit |
23 val tracing_time: bool -> Time.time -> (unit -> string) -> unit |
23 val tracing_time: bool -> Time.time -> (unit -> string) -> unit |
24 val real_time: ('a -> unit) -> 'a -> Time.time |
24 val real_time: ('a -> unit) -> 'a -> Time.time |
25 val synchronized: string -> Mutex.mutex -> (unit -> 'a) -> 'a |
25 val synchronized: string -> Mutex.mutex -> (unit -> 'a) -> 'a |
26 val serial: unit -> int |
|
27 end; |
26 end; |
28 |
27 |
29 structure Multithreading: MULTITHREADING = |
28 structure Multithreading: MULTITHREADING = |
30 struct |
29 struct |
31 |
30 |
145 val result = Exn.capture (restore_attributes e) (); |
144 val result = Exn.capture (restore_attributes e) (); |
146 val _ = if immediate then () else tracing 5 (fn () => name ^ ": unlocking ..."); |
145 val _ = if immediate then () else tracing 5 (fn () => name ^ ": unlocking ..."); |
147 val _ = Mutex.unlock lock; |
146 val _ = Mutex.unlock lock; |
148 in result end) ()); |
147 in result end) ()); |
149 |
148 |
150 |
|
151 (* serial numbers *) |
|
152 |
|
153 local |
|
154 |
|
155 val serial_lock = Mutex.mutex (); |
|
156 val serial_count = ref 0; |
|
157 |
|
158 in |
|
159 |
|
160 val serial = uninterruptible (fn _ => fn () => |
|
161 let |
|
162 val _ = Mutex.lock serial_lock; |
|
163 val _ = serial_count := ! serial_count + 1; |
|
164 val res = ! serial_count; |
|
165 val _ = Mutex.unlock serial_lock; |
|
166 in res end); |
|
167 |
|
168 end; |
149 end; |
169 |
|
170 end; |
|