this repo has no description
at main 560 B view raw
1type t = { pool : Cstruct.t Eio.Stream.t; buf_size : int; capacity : int } 2 3let create ~size ~count = 4 let pool = Eio.Stream.create count in 5 for _ = 1 to count do 6 Eio.Stream.add pool (Cstruct.create size) 7 done; 8 { pool; buf_size = size; capacity = count } 9 10let acquire t = Eio.Stream.take t.pool 11let release t buf = Eio.Stream.add t.pool buf 12 13let with_buffer t f = 14 let buf = acquire t in 15 Fun.protect ~finally:(fun () -> release t buf) (fun () -> f buf) 16 17let available t = Eio.Stream.length t.pool 18let total t = t.capacity 19let size t = t.buf_size