package index

All checked builds pass
  1. Overview
  2. Docs
A platform-agnostic multi-level index for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

index-1.7.0.tbz
sha256=7874a6b68888ca3af1cc252262a1bbad46388b78ecfa9e20109d874d28c02cb2
sha512=c4e9baf0cadd1fe6d8b675e841bb8e1e5401d987b69e94efd62185d5f669d37da56bd94e65e455a8f82de0468cb8a48d314668dde9eabe53ec0e7263d4dd33bb

doc/src/index/platform.ml.html

Source file platform.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
module type IO = Io.S

module type CLOCK = sig
  (** A monotonic time source. See {!Mtime_clock} for an OS-dependent
      implementation. *)

  type counter

  val counter : unit -> counter
  val count : counter -> Mtime.span
end

module type SEMAPHORE = sig
  (** Binary semaphores for mutual exclusion *)

  type t
  (** The type of binary semaphore. *)

  val make : bool -> t
  (** [make b] returns a new semaphore with the given initial state. If [b] is
      [true], the semaphore is initially available for acquisition; otherwise,
      the semaphore is initially unavailable. *)

  val acquire : string -> t -> unit
  (** Acquire the given semaphore. Acquisition is not re-entrant. *)

  val release : t -> unit
  (** Release the given semaphore. If any threads are attempting to acquire the
      semaphore, exactly one of them will gain access to the semaphore. *)

  val with_acquire : string -> t -> (unit -> 'a) -> 'a
  (** [with_acquire t f] first obtains [t], then computes [f ()], and finally
      release [t]. *)

  val is_held : t -> bool
  (** [is_held t] returns [true] if the semaphore is held, without acquiring
      [t]. *)
end

module type THREAD = sig
  (** Cooperative threads. *)

  type 'a t
  (** The type of thread handles. *)

  val async : (unit -> 'a) -> 'a t
  (** [async f] creates a new thread of control which executes [f ()] and
      returns the corresponding thread handle. The thread terminates whenever
      [f ()] returns a value or raises an exception. *)

  val await : 'a t -> ('a, [ `Async_exn of exn ]) result
  (** [await t] blocks on the termination of [t]. *)

  val return : 'a -> 'a t
  (** [return ()] is a pre-terminated thread handle. *)

  val yield : unit -> unit
  (** Re-schedule the calling thread without suspending it. *)
end

module type FMT_TTY = sig
  (** Terminal setup of the standard formatters, as done by [Fmt_tty]. *)

  val setup_std_outputs :
    ?style_renderer:Fmt.style_renderer -> ?utf_8:bool -> unit -> unit
  (** [setup_std_outputs ?style_renderer ?utf_8 ()] sets up the standard
      formatters, as [Fmt_tty.setup_std_outputs] does. *)
end

module type S = sig
  module IO : IO
  module Semaphore : SEMAPHORE
  module Thread : THREAD
  module Clock : CLOCK
  module Progress : Progress_engine.S
  module Fmt_tty : FMT_TTY
end