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

Safe HaskellNone




An unsigned integer (aka Word) LVar that exposes a non-idempotent increment operation. It differs from MaxPosInt in that it allows non-idempotent updates and does _not_ allow least-upper-bound updates.


Monotonically increasing counters

newtype Counter s

A monotonically increasing integral variable.

Note: Currently a Counter is a wrapper around the AtomicCounter exposed by Counter.


Counter (LVar s AtomicCounter Word) 

newCounter :: Word -> Par e s (Counter s)

Create a new Counter with the given initial value.

increment :: HasBump e => Counter s -> Word -> Par e s ()

Increment the counter by a given amount.

waitThresh :: HasGet e => Counter s -> Word -> Par e s ()

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

freezeCounter :: HasFreeze e => Counter s -> Par e s Word

Observe what the final value of the Counter was.

fromCounter :: Counter Frzn -> Word

Once frozen, for example by runParThenFreeze, a Counter can be converted directly into a Word.

Non-monotonic sum accumulators

data Sum s

An integral variable representing a sum of a series of Ints. Unlike Counter, this can go both up and down (positive and negative increments), however it loses the ability to do threshold waiting (waitThresh). The final sum can only be extracted by freezing the variable.

newSum :: Int -> Par e s (Sum s)

Create a new Sum initialized with the given integer.

incrSum :: HasBump e => Sum s -> Par e s ()

Increment the sum by one.

freezeSum :: HasFreeze e => Sum s -> Par e s Int

Observe what the final sum was.