lockfree-queue-0.1: Michael and Scott lock-free queues.

Safe HaskellSafe-Infered



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:




newQ :: IO (LinkedQueue a)

Create a new queue.

nullQ :: LinkedQueue a -> IO Bool

Is the queue currently empty? Beware that this can be a highly transient state.

pushL :: LinkedQueue a -> a -> IO ()

Push a new element onto the queue. Because the queue can grow, this always succeeds.

tryPopR :: LinkedQueue a -> IO (Maybe a)

Attempt to pop an element from the queue if one is available. tryPop will always return promptly, but will return Nothing if the queue is empty.