lvish-2.0: Parallel scheduler, LVar data structures, and infrastructure to build more.

Safe HaskellTrustworthy



A positive integer LVar that contains the maximum value of all puts.



type MaxPosInt s = PureLVar s MC

A MaxPosInt is really a constant-space ongoing fold max operation.

A MaxPosInt is an example of a PureLVar. It is implemented simply as a pure value in a mutable box.

newMaxPosInt :: Int -> Par e s (MaxPosInt s)

Create a new MaxPosInt with the given initial value.

put :: HasPut e => MaxPosInt s -> Int -> Par e s ()

Incorporate a new value in the max-fold. If the previous maximum is less than the new value, increase it.

waitThresh :: HasGet e => MaxPosInt s -> Int -> Par e s ()

Wait until the maximum observed value reaches some threshold, then return.

freezeMaxPosInt :: HasFreeze e => MaxPosInt s -> Par e s Int

Observe what the final value of the MaxPosInt was.

fromMaxPosInt :: MaxPosInt Frzn -> Int

Once frozen, for example by runParThenFreeze, a MaxPosInt can be converted directly into an Int.