equal
deleted
inserted
replaced
46 fun try_change () = |
46 fun try_change () = |
47 let val x = ! var in |
47 let val x = ! var in |
48 (case f x of |
48 (case f x of |
49 SOME (y, x') => (var := x'; SOME y) |
49 SOME (y, x') => (var := x'; SOME y) |
50 | NONE => |
50 | NONE => |
51 if Multithreading.sync_wait (time_limit x) cond lock |
51 (case Multithreading.sync_wait NONE (time_limit x) cond lock of |
52 then try_change () |
52 Exn.Result true => try_change () |
53 else NONE) |
53 | Exn.Result false => NONE |
|
54 | Exn.Exn exn => reraise exn)) |
54 end; |
55 end; |
55 val res = try_change (); |
56 val res = try_change (); |
56 val _ = ConditionVar.broadcast cond; |
57 val _ = ConditionVar.broadcast cond; |
57 in res end); |
58 in res end); |
58 |
59 |