concurrent-0

Safe HaskellNone
LanguageHaskell2010

Concurrent.Capability.LocalArray

Contents

Synopsis

Capability-Local Arrays

data LocalArray a Source

Capability-Local variables with cache-line spacing

You can _only_ safely access these from code that is pinned to a given capability. Otherwise you might get preempted between when we check the capability # and index into the array. At which point the invariants that ensure that we can operate without a compare-and-swap even on the threaded RTS cease to hold.

newLocalArray :: MonadPrimIO m => Int -> a -> m (LocalArray a) Source

Calling setNumCapabilities after this is built can cause you to crash when accessing it and break invariants.

readLocalArray :: forall m a. (MonadPrimIO m, ReifiesCapability m) => LocalArray a -> Int -> m a Source

atomicModifyLocalArray :: (MonadPrimIO m, ReifiesCapability m) => LocalArray a -> Int -> (a -> (a, b)) -> m b Source

This is safely atomic, despite the lack of CAS.

atomicModifyLocalArray' :: (MonadPrimIO m, ReifiesCapability m) => LocalArray a -> Int -> (a -> (a, b)) -> m b Source

This is safely atomic, despite the lack of CAS.

modifyLocalArray :: (MonadPrimIO m, ReifiesCapability m) => LocalArray a -> Int -> (a -> a) -> m a Source

This is safely atomic, despite the lack of CAS.

modifyLocalArray' :: (MonadPrimIO m, ReifiesCapability m) => LocalArray a -> Int -> (a -> a) -> m a Source

This is safely atomic, despite the lack of CAS.

fetchModifyLocalArray :: (MonadPrimIO m, ReifiesCapability m) => LocalArray a -> Int -> (a -> a) -> m a Source

This is safely atomic, despite the lack of CAS.

fetchModifyLocalArray' :: (MonadPrimIO m, ReifiesCapability m) => LocalArray a -> Int -> (a -> a) -> m a Source

This is safely atomic, despite the lack of CAS.

Small Capability-Local Arrays

newSmallLocalArray :: MonadPrimIO m => Int -> a -> m (SmallLocalArray a) Source

Calling setNumCapabilities after this is built can cause you to crash when accessing it and break invariants.

atomicModifySmallLocalArray :: (MonadPrimIO m, ReifiesCapability m) => SmallLocalArray a -> Int -> (a -> (a, b)) -> m b Source

This is safely atomic, despite the lack of CAS.

atomicModifySmallLocalArray' :: (MonadPrimIO m, ReifiesCapability m) => SmallLocalArray a -> Int -> (a -> (a, b)) -> m b Source

This is safely atomic, despite the lack of CAS.

modifySmallLocalArray :: (MonadPrimIO m, ReifiesCapability m) => SmallLocalArray a -> Int -> (a -> a) -> m a Source

This is safely atomic, despite the lack of CAS.

modifySmallLocalArray' :: (MonadPrimIO m, ReifiesCapability m) => SmallLocalArray a -> Int -> (a -> a) -> m a Source

This is safely atomic, despite the lack of CAS.

fetchModifySmallLocalArray :: (MonadPrimIO m, ReifiesCapability m) => SmallLocalArray a -> Int -> (a -> a) -> m a Source

This is safely atomic, despite the lack of CAS.

fetchModifySmallLocalArray' :: (MonadPrimIO m, ReifiesCapability m) => SmallLocalArray a -> Int -> (a -> a) -> m a Source

This is safely atomic, despite the lack of CAS.