Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Michael and Scott lock-free, single-ended queues.
This is a straightforward implementation of classic Michael & Scott Queues. Pseudocode for this algorithm can be found here:
http://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html
Synopsis
- data LinkedQueue a
- newQ :: IO (LinkedQueue a)
- nullQ :: LinkedQueue a -> IO Bool
- pushL :: forall a. LinkedQueue a -> a -> IO ()
- tryPopR :: forall a. LinkedQueue a -> IO (Maybe a)
Documentation
data LinkedQueue a Source #
Instances
DequeClass LinkedQueue Source # | |
Defined in Data.Concurrent.Queue.MichaelScott newQ :: IO (LinkedQueue elt) # nullQ :: LinkedQueue elt -> IO Bool # pushL :: LinkedQueue elt -> elt -> IO () # tryPopR :: LinkedQueue elt -> IO (Maybe elt) # leftThreadSafe :: LinkedQueue elt -> Bool # rightThreadSafe :: LinkedQueue elt -> Bool # |
newQ :: IO (LinkedQueue a) Source #
Create a new queue.
nullQ :: LinkedQueue a -> IO Bool Source #
Is the queue currently empty? Beware that this can be a highly transient state.
pushL :: forall a. LinkedQueue a -> a -> IO () Source #
Push a new element onto the queue. Because the queue can grow, this always succeeds.