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

Safe HaskellNone

Data.Concurrent.Queue.MichaelScott

Description

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

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.

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.