| 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 | (* As of OCaml 4.01.0 input_value and input do not quite work well |
| 12 | * with threads. The symptom is the following. Two threads, each |
| 13 | * of them blocked on a read (on different channels). One is not |
| 14 | * woken up even if data is available. When the other one gets data |
| 15 | * then the stuck one is eventually unblocked too. Unix.select with |
| 16 | * an unbounded wait has the same problem. *) |
| 17 | |
| 18 | (* Use only the following functions on the channel *) |
| 19 | type thread_ic |
| 20 | val prepare_in_channel_for_thread_friendly_io : in_channel -> thread_ic |
| 21 | |
| 22 | val thread_friendly_input_value : thread_ic -> 'a |
| 23 | val thread_friendly_read : |
| 24 | thread_ic -> Bytes.t -> off:int -> len:int -> int |
| 25 | val thread_friendly_really_read : |
| 26 | thread_ic -> Bytes.t -> off:int -> len:int -> unit |
| 27 | val thread_friendly_really_read_line : thread_ic -> string |
| 28 | |
| 29 | (* Wrapper around Thread.create that blocks signals such as Sys.sigalrm (used |
| 30 | * for Timeout *) |
| 31 | val create : ('a -> 'b) -> 'a -> Thread.t |
| 32 | |
| 33 | (* |
| 34 | Atomic mutex lock taken from https://gitlab.com/gadmm/memprof-limits/-/blob/master/src/thread_map.ml#L23-34 |
| 35 | *) |
| 36 | val with_lock : Mutex.t -> scope:(unit -> 'a) -> 'a |