Module Bucket


module Bucket: sig .. end
Bucket-style datastucture

make ~size ~init_level Create a new bucket. Fails if init_level is not within bounds zero;size.

level t Get the current bucket level.

take t x Take some exact amount out of the bucket and return `Taken. If there is not enough left in the bucket, return `Unable.

take_at_most t x Take some amount out of the bucket, possibly emptying it. The return value is the amount that was actually taken out.

fill t x Put some amount into the bucket, possibly overflowing. The return value is the amount that was actually added to the bucket.


module type Contents = sig .. end

Bucket-style datastucture

make ~size ~init_level Create a new bucket. Fails if init_level is not within bounds zero;size.

level t Get the current bucket level.

take t x Take some exact amount out of the bucket and return `Taken. If there is not enough left in the bucket, return `Unable.

take_at_most t x Take some amount out of the bucket, possibly emptying it. The return value is the amount that was actually taken out.

fill t x Put some amount into the bucket, possibly overflowing. The return value is the amount that was actually added to the bucket.

module type S = sig .. end
module Make: 
functor (C : Contents) -> sig .. end
module Int: Make(Std_internal.Int)
module Int64: Make(Std_internal.Int64)
module Float: Make(Float)