equal
deleted
inserted
replaced
39 (map (fn x => fn () => f x) xs); |
39 (map (fn x => fn () => f x) xs); |
40 val results = Future.join_results futures |
40 val results = Future.join_results futures |
41 handle exn => (if Exn.is_interrupt exn then Future.cancel_group group else (); reraise exn); |
41 handle exn => (if Exn.is_interrupt exn then Future.cancel_group group else (); reraise exn); |
42 in results end; |
42 in results end; |
43 |
43 |
44 fun map_name name f xs = Exn.release_first (managed_results name f xs); |
44 fun map_name name f xs = Par_Exn.release_first (managed_results name f xs); |
45 fun map f = map_name "Par_List.map" f; |
45 fun map f = map_name "Par_List.map" f; |
46 |
46 |
47 fun get_some f xs = |
47 fun get_some f xs = |
48 let |
48 let |
49 exception FOUND of 'b option; |
49 exception FOUND of 'b option; |
53 managed_results "Par_List.get_some" |
53 managed_results "Par_List.get_some" |
54 (fn x => (case f x of NONE => () | some => raise FOUND some)) xs; |
54 (fn x => (case f x of NONE => () | some => raise FOUND some)) xs; |
55 in |
55 in |
56 (case get_first found results of |
56 (case get_first found results of |
57 SOME y => SOME y |
57 SOME y => SOME y |
58 | NONE => (Exn.release_first results; NONE)) |
58 | NONE => (Par_Exn.release_first results; NONE)) |
59 end; |
59 end; |
60 |
60 |
61 fun find_some P = get_some (fn x => if P x then SOME x else NONE); |
61 fun find_some P = get_some (fn x => if P x then SOME x else NONE); |
62 |
62 |
63 fun exists P = is_some o get_some (fn x => if P x then SOME () else NONE); |
63 fun exists P = is_some o get_some (fn x => if P x then SOME () else NONE); |