-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A concurrency primitive for a slow consumer. -- -- A concurrency primitive for a slow consumer that can tolerate missing -- some updates. @package next-ref @version 0.1.0.2 -- | This package contains a concurrency primitive which can be used to -- limit an expensive consumer from running unnecessarily. Crucially the -- consumer must be able to tolerate missing some updates. -- -- NextRef provides non-blocking writes, blocking reads, and -- non-blocking reads. -- -- The blocking read interface (takeNextRef) will not necessarily -- present all values. -- -- Additionally the NextRef can be closed. This is useful -- to graceful shutdown the consumer when the producer closes the -- NextRef module Control.Concurrent.NextRef -- | A concurrency primitive for a slow consumer that can tolerate missing -- some updates. data NextRef a -- | Create a NextVar newNextRef :: a -> IO (NextRef a) -- | Block until the next value is available. If the NextVar is -- closed it returns Nothing immediantly. takeNextRef :: NextRef a -> IO (Maybe a) -- | Read the most recent value. Non-blocking readLast :: NextRef a -> IO a -- | Write a new value. Never blocks. writeNextRef :: NextRef a -> a -> IO () -- | Apply a function to current value to produce the next value and return -- a result. modifyNextRef :: NextRef a -> (a -> (a, b)) -> IO b -- | Modify the status of the NextRef to Closed. All future -- reads using takeNextRef will result a Nothing. -- readLast is unaffected. close :: NextRef a -> IO () -- | Modify the status of the NextRef to Closed. All future -- reads using takeNextRef will return a Just. -- readLast is unaffected. open :: NextRef a -> IO () -- | Get the current status of the NextRef status :: NextRef a -> IO Status -- | Status is used to prevent future reads. When the status is -- Closed takeNextRef will always return Nothing. -- When the status is open it will return Just. This is based off of the -- design of TMQueue from the 'stm-chans' package. data Status Open :: Status Closed :: Status instance GHC.Enum.Bounded Control.Concurrent.NextRef.Status instance GHC.Enum.Enum Control.Concurrent.NextRef.Status instance GHC.Read.Read Control.Concurrent.NextRef.Status instance GHC.Classes.Ord Control.Concurrent.NextRef.Status instance GHC.Classes.Eq Control.Concurrent.NextRef.Status instance GHC.Show.Show Control.Concurrent.NextRef.Status