package tcpip
OCaml TCP/IP networking stack, used in MirageOS
Install
Dune Dependency
Authors
Maintainers
Sources
tcpip-8.0.2.tbz
sha256=d452e23f4e62c8b32c977f742e72c50fe673b82e23dc80b29d8263be764d2c72
sha512=9a4aeb5c7ec0392524d1d261026e5de047dec09054f2dca63d9743aed1d27ccfd655ae693554091b4ef7d9eabfeef218e71e8bf13ea8304ebedd8e8a7d4f484a
doc/src/tcpip.tcp/tcptimer.ml.html
Source file tcptimer.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
(* * Copyright (c) 2012 Balraj Singh <bs375@cl.cam.ac.uk> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) open Lwt.Infix let src = Logs.Src.create "tcp.tcptimer" ~doc:"Mirage TCP Tcptimer module" module Log = (val Logs.src_log src : Logs.LOG) type time = int64 type tr = | Stoptimer | Continue of Sequence.t | ContinueSetPeriod of (time * Sequence.t) type t = { expire: (Sequence.t -> tr Lwt.t); mutable period_ns: time; mutable running: bool; } module Make(Time:Mirage_time.S) = struct let t ~period_ns ~expire = let running = false in {period_ns; expire; running} let timerloop t s = Log.debug (fun f -> f "timerloop"); Stats.incr_timer (); let rec aux t s = Log.debug (fun f -> f "timerloop: sleeping for %Lu ns" t.period_ns); Time.sleep_ns t.period_ns >>= fun () -> t.expire s >>= function | Stoptimer -> Stats.decr_timer (); t.running <- false; Log.debug (fun f -> f "timerloop: stoptimer"); Lwt.return_unit | Continue d -> Log.debug (fun f -> f "timerloop: continuer"); aux t d | ContinueSetPeriod (p, d) -> Log.debug (fun f -> f "timerloop: continuesetperiod (new period: %Lu ns)" p); t.period_ns <- p; aux t d in aux t s let period_ns t = t.period_ns let start t ?(p=(period_ns t)) s = if not t.running then begin t.period_ns <- p; t.running <- true; Lwt.async (fun () -> timerloop t s); Lwt.return_unit end else Lwt.return_unit end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>