Debian Codegraph @

lib/control.mli

raw symbols SCIP
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 (** Global control of Rocq. *)
12
13 (** Used to convert signals to exceptions *)
14 exception Timeout
15
16 (** Will periodically call [Thread.delay] if set to true *)
17 val enable_thread_delay : bool ref
18
19 val interrupt : bool ref
20 (** Rocq interruption: set the following boolean reference to interrupt Rocq
21 (it eventually raises [Break], simulating a Ctrl-C) *)
22
23 val check_for_interrupt : unit -> unit
24 (** Use this function as a potential yield function. If {!interrupt} has been
25 set, il will raise [Sys.Break]. *)
26
27 val timeout : float -> ('a -> 'b) -> 'a -> ('b, Exninfo.info) result
28 (** [timeout n f x] tries to compute [Ok (f x)], and if it fails to do
29 so before [n] seconds, returns [Error info] instead (where [info]
30 contains the backtrace of the timeout exception). *)
31
32 (** Set a particular timeout function; warning, this is an internal
33 API and it is scheduled to go away. *)
34 type timeout = { timeout : 'a 'b. float -> ('a -> 'b) -> 'a -> ('b,Exninfo.info) result }
35 val set_timeout : timeout -> unit
36
37 (** [protect_sigalrm f x] computes [f x], but if SIGALRM is received during that
38 computation, the signal handler is executed only once the computation is
39 terminated. Otherwise said, it makes the execution of [f] atomic w.r.t.
40 handling of SIGALRM.
41
42 This is useful for example to prevent the implementation of `Timeout` to
43 interrupt I/O routines, generating ill-formed output.
44
45 *)
46 val protect_sigalrm : ('a -> 'b) -> 'a -> 'b