package current
Pipeline language for keeping things up-to-date
Install
Dune Dependency
Authors
-
TThomas Leonard <talex5@gmail.com>
-
AAntonin Décimo <antonin@tarides.com>
-
TTim McGilchrist <timmcgil@gmail.com>
-
CCraig Ferguson <me@craigfe.io>
-
EEtienne MARAIS <etienne@maiste.fr>
-
AAnil Madhavapeddy <anil@recoil.org>
-
David Allsopp
-
EEwan Mellor <ewan@tarides.com>
-
KKate <kit.ty.kate@disroot.org>
-
MMark Elvers <mark.elvers@tunbury.org>
-
PPuneeth Chaganti <punchagan@muse-amuse.in>
-
LLucas Pluvinage <lucas@tarides.com>
-
NNavin Keswani <navin@novemberkilo.com>
-
TThomas Gazagnaire <thomas@gazagnaire.org>
-
Patrick Ferris
-
AArthur Wendling <art.wendling@gmail.com>
-
AAnurag Soni <anurag@sonianurag.com>
-
AAmbre Austen Suhamy <ambre@tarides.com>
-
BBen Andrew <benmandrew@gmail.com>
-
GGargi Sharma <gs051095@gmail.com>
-
JJonathan Coates <git@squiddev.cc>
-
JJules Aguillon <juloo.dsi@gmail.com>
-
MMagnus Skjegstad <magnus@skjegstad.com>
-
SShon Feder <shon.feder@gmail.com>
-
Ssmolck <46855713+smolck@users.noreply.github.com>
-
Ttatchi <corentin.leruth@gmail.com>
Maintainers
Sources
ocurrent-0.7.1.tbz
md5=8a60e0b0860f6353c0e001d8d74a88ca
sha512=fddde66e3390afa4d46e2d121f2b510358ef853b81b691dbf482b0cfc8f56b21f5a0c43618e1818e6378b8897eca5811af7a995b42e1cb955647727cad877e05
doc/src/current/switch.ml.html
Source file switch.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 73 74 75 76 77 78 79 80 81 82 83 84
(** Like [Lwt_switch], but the cleanup functions are called in sequence, not in parallel, and a reason for the shutdown may be given. *) open Lwt.Infix type callback = unit -> unit Lwt.t type t = { mutable state : [`On of string * callback Stack.t | `Turning_off of unit Lwt.t | `Off]; } let pp_reason f x = Current_term.Output.pp (Fmt.any "()") f (x :> unit Current_term.Output.t) let turn_off t = match t.state with | `Off -> Log.debug (fun f -> f "Switch.turn_off: already off"); Lwt.return_unit | `Turning_off thread -> thread | `On (_, callbacks) -> let th, set_th = Lwt.wait () in t.state <- `Turning_off th; let rec aux () = match Stack.pop callbacks with | fn -> fn () >>= aux | exception Stack.Empty -> t.state <- `Off; Lwt.wakeup set_th (); Lwt.return_unit in aux () (* Once the first callback is added, attach a GC finaliser so we can detect if the user forgets to turn it off. *) let gc t = match t.state with | `Off | `Turning_off _ -> () | `On (label, _) -> Log.err (fun f -> f "Switch %S GC'd while still on!" label); Lwt.async (fun () -> turn_off t) let add_hook_or_fail t fn = match t.state with | `On (_, callbacks) -> if Stack.is_empty callbacks then Gc.finalise gc t; Stack.push fn callbacks | `Off -> Fmt.failwith "Switch already off!" | `Turning_off _ -> Fmt.failwith "Switch is being turned off!" let add_hook_or_exec t fn = match t.state with | `On (_, callbacks) -> if Stack.is_empty callbacks then Gc.finalise gc t; Stack.push fn callbacks; Lwt.return_unit | `Off -> fn () | `Turning_off thread -> thread >>= fn let add_hook_or_exec_opt t fn = match t with | None -> Lwt.return_unit | Some t -> add_hook_or_exec t fn let create ~label () = { state = `On (label, Stack.create ()); } let create_off () = { state = `Off; } let is_on t = match t.state with | `On _ -> true | `Off | `Turning_off _ -> false let pp f t = match t.state with | `On (label, _) -> Fmt.pf f "on(%S)" label | `Off -> Fmt.pf f "off" | `Turning_off _ -> Fmt.string f "turning-off"
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>