License | BSD3 |
---|---|

Maintainer | Julian Sutherland (julian.sutherland10@imperial.ac.uk) |

Safe Haskell | None |

Language | Haskell98 |

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

- data MSQueue r a
- type MSQueueIO a = MSQueue IORef a
- type MSQueueSTM a = MSQueue TVar a
- newMSQueue :: MonadAtomicRef r m => m (MSQueue r a)
- dequeueMSQueue :: MonadAtomicRef r m => MSQueue r a -> m (Maybe a)
- enqueueMSQueue :: MonadAtomicRef r m => MSQueue r a -> a -> m ()

# Documentation

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.

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

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

Enqueues an element in a `MSQueue`

in a lock-free manner.