flush-queue-1.0.0: Concurrent bouded blocking queues optimized for flushing. Both IO and STM implementations.

Copyright(c) FP Complete 2018
LicenseBSD3
MaintainerAlexey Kuleshevich <alexey@fpcomplete.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.BFQueue

Description

Bouded Flush Queue is a very efficient queue that supports pushing elements concurrently, but has no support for popping elements from the queue. The only way to get elements from the queue is to flush it and get all the elements in FIFO order.

Synopsis

Documentation

data BFQueue a Source #

Bounded Flush Queue. It's a queue that allows pushing elements onto, but popping elements is not an option. Only flushing or non-blocking taking from the queue will make space for new elements and unlbock any concurrent writers..

newBFQueue :: Natural -> IO (BFQueue a) Source #

Create new empty BFQueue

writeBFQueue :: BFQueue a -> a -> IO () Source #

O(1) - Push an element onto the queue. Will block if maximum bound has been reached.

tryWriteBFQueue :: BFQueue a -> a -> IO Bool Source #

O(1) - Try to push an element onto the queue without blocking. Will return True if element was pushed successfully, and False in case when the queue is full.

takeBFQueue :: Natural -> BFQueue a -> IO [a] Source #

O(i) - Take i elements from the queue, unblock all the possible writers and return all the elements from the queue in FIFO order.

flushBFQueue :: BFQueue a -> IO [a] Source #

O(n) - Flush the queue, unblock all the possible writers and return all the elements from the queue in FIFO order.

lengthBFQueue :: BFQueue a -> IO Natural Source #

O(1) - Extract number of elements that is currently on the queue

isEmptyBFQueue :: BFQueue a -> IO Bool Source #

O(1) - Check if queue is empty