Safe Haskell | None |
---|
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
- 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
newQ :: IO (LinkedQueue a)Source
Create a new queue.
nullQ :: LinkedQueue a -> IO BoolSource
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.