MSQueue-0.0.1: Michael-Scott queue.

LicenseBSD3
MaintainerJulian Sutherland (julian.sutherland10@imperial.ac.uk)
Safe HaskellNone
LanguageHaskell98

Data.NonBlocking.LockFree.MSQueue

Description

An Implementation of a Michael-Scott Lock-Free queues.

Synopsis

Documentation

data MSQueue r a Source

Implementation of Michael-Scott Lock-Free queues. Specification and pseudo-code can be found at http://www.research.ibm.com/people/m/michael/podc-1996.pdf. Works with any combination of Monad and reference satsfying the MonadAtomicRef class.

type MSQueueIO a = MSQueue IORef a Source

MSQueue inside the IO Monad.

type MSQueueSTM a = MSQueue TVar a Source

MSQueue inside the STM Monad.

newMSQueue :: MonadAtomicRef r m => m (MSQueue r a) Source

Creates a new instance of MSQueue. Internally implemented with a reference of type r, which is why they must be atomically modifiable. Initially empty.

dequeueMSQueue :: MonadAtomicRef r m => MSQueue r a -> m (Maybe a) Source

Dequeues an element from a MSQueue in a lock-free manner. Returns Nothing if the queue is empty, otherwise return the element wrapped in a Just.

enqueueMSQueue :: MonadAtomicRef r m => MSQueue r a -> a -> m () Source

Enqueues an element in a MSQueue in a lock-free manner.