Safe Haskell | Unsafe |
---|---|
Language | Haskell2010 |
- newtype PrimRef s a = PrimRef (MutableByteArray s)
- newPrimRef :: (PrimMonad m, Prim a) => a -> m (PrimRef (PrimState m) a)
- newPinnedPrimRef :: (PrimMonad m, Prim a) => a -> m (PrimRef (PrimState m) a)
- newAlignedPinnedPrimRef :: (PrimMonad m, Prim a) => a -> m (PrimRef (PrimState m) a)
- readPrimRef :: (PrimMonad m, Prim a) => PrimRef (PrimState m) a -> m a
- writePrimRef :: (PrimMonad m, Prim a) => PrimRef (PrimState m) a -> a -> m ()
- primRefContents :: PrimRef s a -> Addr
- newtype FrozenPrimRef a = FrozenPrimRef ByteArray
- newFrozenPrimRef :: Prim a => a -> FrozenPrimRef a
- unsafeFreezePrimRef :: PrimMonad m => PrimRef (PrimState m) a -> m (FrozenPrimRef a)
- unsafeThawPrimRef :: PrimMonad m => FrozenPrimRef a -> m (PrimRef (PrimState m) a)
- indexFrozenPrimRef :: Prim a => FrozenPrimRef a -> a
- frozenPrimRefContents :: FrozenPrimRef a -> Addr
- casInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> Int -> m Int
- fetchAddInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int
- fetchSubInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int
- fetchAndInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int
- fetchNandInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int
- fetchOrInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int
- fetchXorInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int
- atomicReadInt :: PrimMonad m => PrimRef (PrimState m) Int -> m Int
- atomicWriteInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m ()
- prefetchPrimRef0 :: PrimMonad m => PrimRef (PrimState m) a -> m ()
- prefetchPrimRef1 :: PrimMonad m => PrimRef (PrimState m) a -> m ()
- prefetchPrimRef2 :: PrimMonad m => PrimRef (PrimState m) a -> m ()
- prefetchPrimRef3 :: PrimMonad m => PrimRef (PrimState m) a -> m ()
- prefetchFrozenPrimRef0 :: PrimMonad m => FrozenPrimRef a -> m ()
- prefetchFrozenPrimRef1 :: PrimMonad m => FrozenPrimRef a -> m ()
- prefetchFrozenPrimRef2 :: PrimMonad m => FrozenPrimRef a -> m ()
- prefetchFrozenPrimRef3 :: PrimMonad m => FrozenPrimRef a -> m ()
Primitive References
newPrimRef :: (PrimMonad m, Prim a) => a -> m (PrimRef (PrimState m) a) Source
Create a primitive reference.
newPinnedPrimRef :: (PrimMonad m, Prim a) => a -> m (PrimRef (PrimState m) a) Source
Create a pinned primitive reference.
newAlignedPinnedPrimRef :: (PrimMonad m, Prim a) => a -> m (PrimRef (PrimState m) a) Source
Create a pinned primitive reference with the appropriate alignment for its contents.
readPrimRef :: (PrimMonad m, Prim a) => PrimRef (PrimState m) a -> m a Source
Read a primitive value from the reference
writePrimRef :: (PrimMonad m, Prim a) => PrimRef (PrimState m) a -> a -> m () Source
Write a primitive value to the reference
primRefContents :: PrimRef s a -> Addr Source
Yield a pointer to the data of a PrimRef
. This operation is only safe on pinned byte arrays allocated by
newPinnedPrimRef
or newAlignedPinnedPrimRef
.
Frozen Primitive References
newtype FrozenPrimRef a Source
FrozenPrimRef ByteArray |
(Prim a, Data a) => Data (FrozenPrimRef a) Source |
newFrozenPrimRef :: Prim a => a -> FrozenPrimRef a Source
unsafeFreezePrimRef :: PrimMonad m => PrimRef (PrimState m) a -> m (FrozenPrimRef a) Source
Convert a mutable PrimRef
to an immutable one without copying. The reference should not be modified after the conversion.
unsafeThawPrimRef :: PrimMonad m => FrozenPrimRef a -> m (PrimRef (PrimState m) a) Source
Convert an immutable primitive reference to a mutable one without copying. The original reference should not be used after the conversion.
indexFrozenPrimRef :: Prim a => FrozenPrimRef a -> a Source
Read the stored primitive value from the frozen reference.
frozenPrimRefContents :: FrozenPrimRef a -> Addr Source
Yield a pointer to the data of a FrozenPrimRef
. This operation is only safe on pinned byte arrays allocated by
newPinnedPrimRef
or newAlignedPinnedPrimRef
and then subsequently frozen.
Atomic Operations
casInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> Int -> m Int Source
Given a primitive reference, the expected old value, and the new value, perform an atomic compare and swap i.e. write the new value if the current value matches the provided old value. Returns the value of the element before the operation. Implies a full memory barrier.
fetchAddInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int Source
Given a reference, and a value to add, atomically add the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.
fetchSubInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int Source
Given a reference, and a value to subtract, atomically subtract the value from the element. Returns the value of the element before the operation. Implies a full memory barrier.
fetchAndInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int Source
Given a reference, and a value to bitwise and, atomically and the value with the element. Returns the value of the element before the operation. Implies a full memory barrier.
fetchNandInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int Source
Given a reference, and a value to bitwise nand, atomically nand the value with the element. Returns the value of the element before the operation. Implies a full memory barrier.
fetchOrInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int Source
Given a reference, and a value to bitwise or, atomically or the value with the element. Returns the value of the element before the operation. Implies a full memory barrier.
fetchXorInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int Source
Given a reference, and a value to bitwise xor, atomically xor the value with the element. Returns the value of the element before the operation. Implies a full memory barrier.
atomicReadInt :: PrimMonad m => PrimRef (PrimState m) Int -> m Int Source
Given a reference, read an element. Implies a full memory barrier.
atomicWriteInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m () Source
Given a reference, write an element. Implies a full memory barrier.
Prefetching
prefetchPrimRef0 :: PrimMonad m => PrimRef (PrimState m) a -> m () Source
prefetchPrimRef1 :: PrimMonad m => PrimRef (PrimState m) a -> m () Source
prefetchPrimRef2 :: PrimMonad m => PrimRef (PrimState m) a -> m () Source
prefetchPrimRef3 :: PrimMonad m => PrimRef (PrimState m) a -> m () Source
prefetchFrozenPrimRef0 :: PrimMonad m => FrozenPrimRef a -> m () Source
prefetchFrozenPrimRef1 :: PrimMonad m => FrozenPrimRef a -> m () Source
prefetchFrozenPrimRef2 :: PrimMonad m => FrozenPrimRef a -> m () Source
prefetchFrozenPrimRef3 :: PrimMonad m => FrozenPrimRef a -> m () Source