-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Concurrent bouded blocking queues optimized for flushing. Both IO and STM implementations.
--
-- Please see the README on GitHub at
-- https://github.com/fpco/flush-queue#readme
@package flush-queue
@version 1.0.0
-- | 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.
module Control.Concurrent.BFQueue
-- | 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..
data BFQueue a
-- | Create new empty BFQueue
newBFQueue :: Natural -> IO (BFQueue a)
-- | O(1) - Push an element onto the queue. Will block if maximum
-- bound has been reached.
writeBFQueue :: BFQueue a -> a -> IO ()
-- | 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.
tryWriteBFQueue :: BFQueue a -> a -> IO Bool
-- | O(i) - Take i elements from the queue, unblock all the
-- possible writers and return all the elements from the queue in FIFO
-- order.
takeBFQueue :: Natural -> BFQueue a -> IO [a]
-- | O(n) - Flush the queue, unblock all the possible writers and
-- return all the elements from the queue in FIFO order.
flushBFQueue :: BFQueue a -> IO [a]
-- | O(1) - Extract number of elements that is currently on the
-- queue
lengthBFQueue :: BFQueue a -> IO Natural
-- | O(1) - Check if queue is empty
isEmptyBFQueue :: BFQueue a -> IO Bool
-- | Transactional Bouded Flush Queue is a very similar to BFQueue,
-- with an exception that it runs in STM and is also less
-- efficient, but is still faster than TBQueue.
module Control.Concurrent.STM.TBFQueue
-- | Bounded Flush Queue. It's a queue that allows pushing elements onto,
-- popping elements from it, but is mostly optimizied for flushing the
-- queue or taking in bulk.
data TBFQueue a
-- | Construct a new empty Flush Bounded Queue
newTBFQueue :: Natural -> STM (TBFQueue a)
-- | Construct a new empty Flush Bounded Queue inside IO monad.
newTBFQueueIO :: Natural -> IO (TBFQueue a)
-- | O(1) - Push an element onto the queue. Will block if maximum
-- bound has been reached.
writeTBFQueue :: TBFQueue a -> a -> STM ()
-- | 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.
tryWriteTBFQueue :: TBFQueue a -> a -> STM Bool
-- | Amortized O(1) - Pop an element from the queue. Will block if
-- queue is empty.
readTBFQueue :: TBFQueue a -> STM a
-- | O(i) - Take i elements from the queue, unblock all the
-- possible writers and return all the elements from the queue in FIFO
-- order.
takeTBFQueue :: Natural -> TBFQueue a -> STM [a]
-- | O(n) - Flush the queue, unblock all the possible writers and
-- return all the elements from the queue in FIFO order.
flushTBFQueue :: TBFQueue a -> STM [a]
-- | O(1) - Extract number of elements that is currently on the
-- queue
lengthTBFQueue :: TBFQueue a -> STM Natural
-- | O(1) - Check if queue is empty
isEmptyTBFQueue :: TBFQueue a -> STM Bool