package luv

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file semaphore.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
(* This file is part of Luv, released under the MIT license. See LICENSE.md for
   details, or visit https://github.com/aantron/luv/blob/master/LICENSE.md. *)



type t = C.Types.Semaphore.t Ctypes.ptr

let init count =
  let semaphore = Ctypes.addr (Ctypes.make C.Types.Semaphore.t) in
  C.Functions.Semaphore.init semaphore (Unsigned.UInt.of_int count)
  |> Error.to_result semaphore

let destroy =
  C.Functions.Semaphore.destroy

let post =
  C.Functions.Semaphore.post

let wait =
  C.Blocking.Semaphore.wait

let trywait semaphore =
  C.Functions.Semaphore.trywait semaphore
  |> Error.to_result ()
OCaml

Innovation. Community. Security.