package index

  1. Overview
  2. Docs
A platform-agnostic multi-level index for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

index-1.6.1.tbz
sha256=acfc0dcea916a836a4da60d30c806a22f69c858d6f7ce233166c1a5e365e6bee
sha512=78c45c71c1194d6e118c5cf3920d84c571d0f61f8fa3467f72e7c17c4bbab8e01a5efdb6a96a5328a7b3c5bbf01b0b31e42525c66f4be72d986530ef0ec7cec5

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
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 S = sig
  module IO : IO
  module Semaphore : SEMAPHORE
  module Thread : THREAD
  module Clock : CLOCK
end
OCaml

Innovation. Community. Security.