equal
deleted
inserted
replaced
11 val ! : 'a ref -> 'a |
11 val ! : 'a ref -> 'a |
12 val change: 'a ref -> ('a -> 'a) -> unit |
12 val change: 'a ref -> ('a -> 'a) -> unit |
13 val change_result: 'a ref -> ('a -> 'b * 'a) -> 'b |
13 val change_result: 'a ref -> ('a -> 'b * 'a) -> 'b |
14 val inc: int ref -> int |
14 val inc: int ref -> int |
15 val dec: int ref -> int |
15 val dec: int ref -> int |
|
16 val add: int ref -> int -> int |
16 val setmp: 'a ref -> 'a -> ('b -> 'c) -> 'b -> 'c |
17 val setmp: 'a ref -> 'a -> ('b -> 'c) -> 'b -> 'c |
17 end; |
18 end; |
18 |
19 |
19 structure Unsynchronized: UNSYNCHRONIZED = |
20 structure Unsynchronized: UNSYNCHRONIZED = |
20 struct |
21 struct |
27 fun change r f = r := f (! r); |
28 fun change r f = r := f (! r); |
28 fun change_result r f = let val (x, y) = f (! r) in r := y; x end; |
29 fun change_result r f = let val (x, y) = f (! r) in r := y; x end; |
29 |
30 |
30 fun inc i = (i := ! i + (1: int); ! i); |
31 fun inc i = (i := ! i + (1: int); ! i); |
31 fun dec i = (i := ! i - (1: int); ! i); |
32 fun dec i = (i := ! i - (1: int); ! i); |
|
33 fun add i n = (i := ! i + (n: int); ! i); |
32 |
34 |
33 fun setmp flag value f x = |
35 fun setmp flag value f x = |
34 Thread_Attributes.uninterruptible (fn restore_attributes => fn () => |
36 Thread_Attributes.uninterruptible (fn restore_attributes => fn () => |
35 let |
37 let |
36 val orig_value = ! flag; |
38 val orig_value = ! flag; |