package tiny_httpd
Minimal HTTP server using threads
Install
Dune Dependency
Authors
Maintainers
Sources
tiny_httpd-0.18.tbz
sha256=ef806444b2f9e53d10976b9124902560d0855124433537080e6d0bec48d202e5
sha512=539530eb9e511b6ed4d69bb083f421d5f51b183c347c116a52f24210f30b1c9b14a029e2b82d6e0d698c74ab75ba5c307a1976711558a1419df287335b2a8f51
doc/src/tiny_httpd.core/pool.ml.html
Source file pool.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
module A = Atomic_ type 'a list_ = Nil | Cons of int * 'a * 'a list_ type 'a t = { mk_item: unit -> 'a; clear: 'a -> unit; max_size: int; (** Max number of items *) items: 'a list_ A.t; } let create ?(clear = ignore) ~mk_item ?(max_size = 512) () : _ t = { mk_item; clear; max_size; items = A.make Nil } let rec acquire_ self = match A.get self.items with | Nil -> self.mk_item () | Cons (_, x, tl) as l -> if A.compare_and_set self.items l tl then x else acquire_ self let[@inline] size_ = function | Cons (sz, _, _) -> sz | Nil -> 0 let release_ self x : unit = let rec loop () = match A.get self.items with | Cons (sz, _, _) when sz >= self.max_size -> (* forget the item *) () | l -> if not (A.compare_and_set self.items l (Cons (size_ l + 1, x, l))) then loop () in self.clear x; loop () let with_resource (self : _ t) f = let x = acquire_ self in try let res = f x in release_ self x; res with e -> let bt = Printexc.get_raw_backtrace () in release_ self x; Printexc.raise_with_backtrace e bt
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>