Description
Mutable variable with primitive values.
Description
Mutable variable PVar
that is backed by a single value MutableByteArray
README.md
pvar
Interface for a mutable variable PVar
that can hold values that have Prim
instance.
Status
Language | Travis | Azure | Coveralls |
---|---|---|---|
Package | Hackage | Nightly | LTS |
---|---|---|---|
pvar |
Overview
Main features include:
- Performance. There is practically no overhead when compared to operating on pure values, although there is a higher memory overhead, since
PVar
is backed by aMutableByteArray#
- Atomic operations for
PVar
s withInt
values. This includes a unique function that is not available inghc-prim
out of the box:
atomicModifyIntPVar :: PrimMonad m => PVar m Int -> (Int -> (Int, a)) -> m a
- Works in
PrimMonad
, therefore it is usable withST
,IO
and various transformer monads. - Easy access to
PVar
contents withStorable
isByteArrayPinned
,isMutableByteArrayPinned
function that work on ghc-7.10 and ghc-8.0 as well as all the newer ones.