open Types (* type loc = int * int *) module LocIntMap = Map.Make (struct type t = int * int let compare = compare end) let locintmap_to_list m = LocIntMap.fold (fun id v acc -> (id, v) :: acc) m [] let failed_location_set = ref LocIntMap.empty let add_failed_location loc = if LocIntMap.mem loc !failed_location_set then let n = LocIntMap.find loc !failed_location_set in failed_location_set := LocIntMap.add loc (n + 50) !failed_location_set else failed_location_set := LocIntMap.add loc 50 !failed_location_set let aging() = failed_location_set := LocIntMap.fold (fun loc n result -> let n = n - 1 in if n <= 0 then result else LocIntMap.add loc n result) (!failed_location_set) LocIntMap.empty let too_often loc = if LocIntMap.mem loc !failed_location_set then let n = LocIntMap.find loc !failed_location_set in n > 200 else false let print() = print_string ("failure list:\n"); let print loc n = let x, y = loc in print_string ("("^(string_of_int x)^","^(string_of_int y)^") = "^(string_of_int n)^"\n") in LocIntMap.iter print (!failed_location_set)