rcu-0: STM-based Read-Copy-Update

Copyright(C) 2015 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.RCU.Internal

Description

STM-based RCU with concurrent writers

Synopsis

Documentation

newtype SRef s a Source

Shared references

Constructors

SRef 

Fields

unSRef :: TVar a
 

Instances

Eq (SRef s a) Source 

data RCUThread s a Source

This is a basic RCU thread. It may be embellished when running in a more exotic context.

Constructors

RCUThread 

Fields

rcuThreadId :: !ThreadId
 
rcuThreadVar :: !(MVar a)
 

newtype RCU s a Source

This is an RCU computation. It can use forking and joining to form new threads, and then you can use reading and writing to run classic read-side and write-side RCU computations. Contention between multiple write-side computations is managed by STM.

Constructors

RCU 

Fields

unRCU :: TVar Int64 -> IO a
 

runRCU :: (forall s. RCU s a) -> IO a Source

Run an RCU computation.

newtype ReadingRCU s a Source

This is the basic read-side critical section for an RCU computation

Constructors

ReadingRCU 

Fields

runReadingRCU :: IO a
 

newtype WritingRCU s a Source

This is the basic write-side critical section for an RCU computation

Constructors

WritingRCU 

Fields

runWritingRCU :: TVar Int64 -> STM a
 

class Monad m => MonadNew s m | m -> s where Source

Minimal complete definition

Nothing

Methods

newSRef :: a -> m (SRef s a) Source

Build a new shared reference

Instances

MonadNew s (RCU s) Source 
MonadNew s (WritingRCU s) Source 
MonadNew s (ReadingRCU s) Source 
MonadNew s m => MonadNew s (IdentityT m) Source 
MonadNew s m => MonadNew s (MaybeT m) Source 
MonadNew s m => MonadNew s (ExceptT e m) Source 
MonadNew s' m => MonadNew s' (StateT s m) Source 
MonadNew s' m => MonadNew s' (StateT s m) Source 
(MonadNew s m, Monoid w) => MonadNew s (WriterT w m) Source 
(MonadNew s m, Monoid w) => MonadNew s (WriterT w m) Source 
MonadNew s m => MonadNew s (ReaderT e m) Source 
(MonadNew s' m, Monoid w) => MonadNew s' (RWST r w s m) Source 
(MonadNew s' m, Monoid w) => MonadNew s' (RWST r w s m) Source 

class MonadNew s m => MonadReading s m | m -> s where Source

This is a read-side critical section

Minimal complete definition

Nothing

Methods

readSRef :: SRef s a -> m a Source

Read a shared reference.

copySRef :: MonadReading s m => SRef s a -> m (SRef s a) Source

Copy a shared reference.

class MonadReading s m => MonadWriting s m | m -> s where Source

This is a write-side critical section

Minimal complete definition

Nothing

Methods

writeSRef :: SRef s a -> a -> m () Source

Write to a shared reference.

synchronize :: m () Source

Synchronize with other writers.

No other writer can straddle this time bound. It will either see writes from before, or writes after, but never some of both!

class (MonadReading s (Reading m), MonadWriting s (Writing m), MonadNew s m) => MonadRCU s m | m -> s where Source

This is the executor service that can fork, join and execute critical sections.

Associated Types

type Reading m :: * -> * Source

A read-side critical section

type Writing m :: * -> * Source

A write-side critical section

type Thread m :: * -> * Source

Threads we can fork and join

Methods

forking :: m a -> m (Thread m a) Source

Fork a thread

joining :: Thread m a -> m a Source

Join a thread

reading :: Reading m a -> m a Source

Run a read-side critical section

writing :: Writing m a -> m a Source

Run a write-side critical section

Instances

MonadRCU s (RCU s) Source 
MonadRCU s m => MonadRCU s (MaybeT m) Source 
MonadRCU s m => MonadRCU s (IdentityT m) Source 
(MonadRCU s m, Monoid e) => MonadRCU s (WriterT e m) Source 
(MonadRCU s m, Monoid e) => MonadRCU s (WriterT e m) Source 
MonadRCU s m => MonadRCU s (ExceptT e m) Source 
MonadRCU s m => MonadRCU s (ReaderT e m) Source