1024" x-on:close-sidebar="sidebar=window.innerWidth > 1024 && true">
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
val fresh_state : id:string -> refresh_interval:float -> state
fresh_state ~id ~refresh_interval
initializes the state of a worker handling a family of counter. The worker wakes up every refresh_interval
seconds. id
is a string identifier used for distinguishing distinct Moving_average workers..
create state ~init ~alpha
is a counter with initial value init
and factor alpha
. The counter is added to the state
. It is not removed automatically: it must be removed manually.
val add : t -> int -> unit
add state t v
adds v
to the counter t
.
val on_update : state -> ( unit -> unit ) -> unit
on_update state f
registers f
to be called on each update of the internal worker associated to state
.
val updated : state -> unit Lwt_condition.t
updated state
is a condition variable that gets signaled on each update of the internal worker..