package riot
An actor-model multi-core scheduler for OCaml 5
Install
Dune Dependency
Authors
Maintainers
Sources
riot-0.0.5.tbz
sha256=01b7b82ccc656b12b7315960d9df17eb4682b8f1af68e9fee33171fee1f9cf88
sha512=d8831d8a75fe43a7e8d16d2c0bb7d27f6d975133e17c5dd89ef7e575039c59d27c1ab74fbadcca81ddfbc0c74d1e46c35baba35ef825b36ac6c4e49d7a41d0c2
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)"
>