package riot
An actor-model multi-core scheduler for OCaml 5
Install
Dune Dependency
Authors
Maintainers
Sources
riot-0.0.4.tbz
sha256=bd196369f74bbc42f23d262030d5fa04c03f5f00c46bf944f0dcbc193745976f
sha512=f1ca69e05b57e83a1bd173efe51b745d331355a83381e6068743a7626e45dcf515cdd8947180051bddfe9f5727c2732aa0f01a093b04cf33fa4081d32f24fd65
doc/src/riot.util/fd.ml.html
Source file fd.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
module Mode = struct type t = [ `r | `rw | `w ] let equal a b = match (a, b) with | `r, `r -> true | `w, `w -> true | `rw, `rw -> true | _ -> false let pp fmt t = let mode = match t with `r -> "r" | `w -> "w" | `rw -> "rw" in Format.fprintf fmt "%s" mode end type fd = Unix.file_descr type state = [ `Open of fd | `Closed ] type t = { state : state Atomic.t; fd : fd } exception Already_closed of string let is_closed t = Atomic.get t.state = `Closed let is_open t = not (is_closed t) let get t = match Atomic.get t.state with `Open sock -> Some sock | `Closed -> None let equal a b = match (get a, get b) with | Some fd1, Some fd2 -> Int.equal (Obj.magic fd1) (Obj.magic fd2) | _ -> false let to_int t = match Atomic.get t.state with | `Open fd -> Obj.magic fd | `Closed -> Obj.magic t.fd let pp fmt t = if is_closed t then Format.fprintf fmt "Fd.closed(%d)" (to_int t) else Format.fprintf fmt "Fd(%d)" (to_int t) let rec close t = match Atomic.get t.state with | `Closed -> () | `Open fd as prev -> let next = `Closed in if Atomic.compare_and_set t.state prev next then Unix.close fd else close t let make fd = { state = Atomic.make (`Open fd); fd } let use ~op_name t fn = match get t with | Some sock -> fn sock | None -> raise (Already_closed (op_name ^ ": fd already closed"))
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>