Utils: add Ring.clear

This commit is contained in:
Benjamin Canou 2017-12-07 14:31:28 +01:00 committed by Grégoire Henry
parent bb90cc9dec
commit 9b09e70f5e
2 changed files with 9 additions and 0 deletions

View File

@ -40,6 +40,12 @@ let add_and_return_erased r v =
None in
add r v ; replaced
let clear r =
match !r with
| Empty _ -> ()
| Inited { data ; _ } ->
r := Empty (Array.length data)
let add_list r l = List.iter (add r) l
let last r =

View File

@ -27,6 +27,9 @@ val add_and_return_erased : 'a t -> 'a -> 'a option
(** Adds the values of a list, in order. *)
val add_list : 'a t -> 'a list -> unit
(** Removes all values in the ring buffer. *)
val clear : 'a t -> unit
(** Retrieves the most recent value, or [None] when empty. *)
val last : 'a t -> 'a option