lockfree-queue-0.2.4: Michael and Scott lock-free queues.
Safe HaskellSafe-Inferred



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:




data LinkedQueue a Source #


Instances details
DequeClass LinkedQueue Source # 
Instance details

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.

tryPopR :: forall a. LinkedQueue a -> IO (Maybe a) Source #

Attempt to pop an element from the queue if one is available. tryPop will return semi-promptly (depending on contention), but will return Nothing if the queue is empty.