let am_holding_mutex mtx = match try if try_lock mtx then `Free else `Held_by_other with _ -> `Held_by_me with | `Free -> unlock mtx; false | `Held_by_me -> true | `Held_by_other -> false