massiv-0.5.2.0: Massiv (Массив) is an Array Library.

Copyright(c) Alexey Kuleshevich 2018-2019
LicenseBSD3
MaintainerAlexey Kuleshevich <lehins@yandex.ru>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Massiv.Array.Mutable.Atomic

Contents

Description

 
Synopsis

Atomic element-wise mutation

atomicReadIntArray :: (Index ix, PrimMonad m) => MArray (PrimState m) P ix Int -> ix -> m (Maybe Int) Source #

Atomically read an Int element from the array

Since: 0.3.0

atomicWriteIntArray :: (Index ix, PrimMonad m) => MArray (PrimState m) P ix Int -> ix -> Int -> m Bool Source #

Atomically write an Int element int the array. Returns True if supplied index was correct and write was successfull.

Since: 0.3.0

atomicModifyIntArray :: (Index ix, PrimMonad m) => MArray (PrimState m) P ix Int -> ix -> (Int -> Int) -> m (Maybe Int) Source #

Atomically modify an Int element of the array. Returns the old value, unless the supplied index was out of bounds.

Since: 0.3.0

atomicAddIntArray :: (Index ix, PrimMonad m) => MArray (PrimState m) P ix Int -> ix -> Int -> m (Maybe Int) Source #

Atomically add to an Int element in the array. Returns the old value.

Since: 0.3.0

atomicSubIntArray :: (Index ix, PrimMonad m) => MArray (PrimState m) P ix Int -> ix -> Int -> m (Maybe Int) Source #

Atomically subtract from an Int element in the array. Returns the old value.

Since: 0.3.0

atomicAndIntArray :: (Index ix, PrimMonad m) => MArray (PrimState m) P ix Int -> ix -> Int -> m (Maybe Int) Source #

Atomically AND an Int element in the array. Returns the old value.

Since: 0.3.0

atomicNandIntArray :: (Index ix, PrimMonad m) => MArray (PrimState m) P ix Int -> ix -> Int -> m (Maybe Int) Source #

Atomically NAND an Int element in the array. Returns the old value.

Since: 0.3.0

atomicOrIntArray :: (Index ix, PrimMonad m) => MArray (PrimState m) P ix Int -> ix -> Int -> m (Maybe Int) Source #

Atomically OR an Int element in the array. Returns the old value.

Since: 0.3.0

atomicXorIntArray :: (Index ix, PrimMonad m) => MArray (PrimState m) P ix Int -> ix -> Int -> m (Maybe Int) Source #

Atomically XOR an Int element in the array. Returns the old value.

Since: 0.3.0

casIntArray Source #

Arguments

:: (Index ix, PrimMonad m) 
=> MArray (PrimState m) P ix Int

Array to mutate

-> ix

Index at which to mutate

-> Int

Expected value

-> Int

New value

-> m (Maybe Int) 

Atomically CAS (Compare-and-Swap) an Int in the array. Returns the old value.

Since: 0.3.0