package obatcher
A Framework for building Batched Concurrent Data Structures
Install
Dune Dependency
Authors
Maintainers
Sources
obatcher-1.1.tbz
sha256=2ee8f97a1e4a55899f8fdc48aa422e553d6a4d256e71b59e4257448beaf27dd3
sha512=61d0645dc5bd6955f3e663f133d27d9c8c61081e24bc8d88e73f86380432e783fa50bc4d980a9b17ccb949f6af9b90ef834f379ec9171b692745f05d9a34c0f9
doc/src/obatcher.ds/batched_counter.ml.html
Source file batched_counter.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
open Picos module Batched = struct type t = int Atomic.t type cfg = unit let init ?cfg:_ () = Atomic.make 0 type _ op = Incr : unit op | Decr : unit op | Get : int op type wrapped_op = Mk : 'a op * 'a Computation.t -> wrapped_op let run (t : t) (ops : wrapped_op array) = let len = Array.length ops in let start = Atomic.get t in let delta = Utils.parallel_for_reduce ~n_fibers:(Domain.recommended_domain_count () - 1) ~start:0 ~finish:(len - 1) ~body:(fun i -> match ops.(i) with | Mk (Incr, comp) -> Computation.return comp (); 1 | Mk (Decr, comp) -> Computation.return comp (); -1 | Mk (Get, comp) -> Computation.return comp start; 0) ( + ) 0 in Atomic.set t (start + delta) end (* Set up implicit batching *) include Obatcher.Make (Batched) let incr t = exec t Incr let decr t = exec t Decr let get t = let got = exec t Get in got
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>