| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | (* Thread safe queue with some extras *) |
| 12 | |
| 13 | type 'a t |
| 14 | val create : unit -> 'a t |
| 15 | val pop : ?picky:('a -> bool) -> ?destroy:bool ref -> 'a t -> 'a |
| 16 | val push : 'a t -> 'a -> unit |
| 17 | val set_order : 'a t -> ('a -> 'a -> int) -> unit |
| 18 | val wait_until_n_are_waiting_and_queue_empty : int -> 'a t -> unit |
| 19 | |
| 20 | (* Wake up all waiting threads *) |
| 21 | val broadcast : 'a t -> unit |
| 22 | |
| 23 | (* Non destructive *) |
| 24 | val wait_until_n_are_waiting_then_snapshot : int -> 'a t -> 'a list |
| 25 | |
| 26 | val clear : 'a t -> unit |
| 27 | val clear_saving : 'a t -> ('a -> 'b option) -> 'b list |
| 28 | val is_empty : 'a t -> bool |
| 29 | |
| 30 | exception BeingDestroyed |
| 31 | (* Threads blocked in pop can get this exception if the queue is being |
| 32 | * destroyed *) |
| 33 | val destroy : 'a t -> unit |
| 34 | |
| 35 | val length : 'a t -> int |