let iter_and_take_callbacks f = let rec loop () = loop (f (Queue.take callbacks)) in try loop () with | Queue.Empty -> ()