unliftio-messagebox-2.0.0: Fast and robust message queues for concurrent processes
Safe HaskellNone
LanguageHaskell2010

UnliftIO.MessageBox.Limited

Description

Thread safe queues for uni directional message passing between threads.

This message box has an upper limit, that means that sometimes delivery either fails or is blocked until the receiving thread has consumed more messages.

Use this module if the producer(s) outperform the consumer, but you want the extra safety that the queue blocks the Input after a certain message limit is reached.

If you are sure that the producers fire at a slower rate then the rate at which the consumer consumes messages, use this module.

Synopsis

Documentation

data MessageLimit Source #

Message Limit

The message limit must be a reasonable small positive integer that is also a power of two. This stems from the fact that Unagi is used under the hood.

The limit is a lower bound.

messageLimitToInt :: MessageLimit -> Int Source #

Convert a MessageLimit to the Int representation.

newtype BlockingBoxLimit Source #

Contains the (vague) limit of messages that a BlockingBox can buffer, i.e. that deliver can put into a BlockingInput of a BlockingBox.

data BlockingBox a Source #

A message queue out of which messages can by received.

This is the counter part of Input. Can be used for reading messages.

Messages can be received by receive or tryReceive.

Instances

Instances details
IsMessageBox BlockingBox Source #

A blocking instance that invokes receive.

Instance details

Defined in UnliftIO.MessageBox.Limited

Associated Types

type Input BlockingBox :: Type -> Type Source #

type Input BlockingBox Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

data BlockingInput a Source #

A message queue into which messages can be enqued by, e.g. tryToDeliver. Messages can be received from an BlockingBox.

The Input is the counter part of a BlockingBox.

Instances

Instances details
IsInput BlockingInput Source #

A blocking instance that invokes deliver.

Instance details

Defined in UnliftIO.MessageBox.Limited

Methods

deliver :: MonadUnliftIO m => BlockingInput a -> a -> m Bool Source #

deliver_ :: MonadUnliftIO m => BlockingInput a -> a -> m () Source #

newtype NonBlockingBoxLimit Source #

A BlockingBoxLimit wrapper for non-blocking IsMessageBoxArg instances.

Instances

Instances details
Eq NonBlockingBoxLimit Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

Ord NonBlockingBoxLimit Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

Show NonBlockingBoxLimit Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

IsMessageBoxArg NonBlockingBoxLimit Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

Associated Types

type MessageBox NonBlockingBoxLimit :: Type -> Type Source #

type MessageBox NonBlockingBoxLimit Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

data NonBlockingBox a Source #

A BlockingBox wrapper for non-blocking IsMessageBox instances.

The difference to the BlockingBox instance is that deliver immediately returns if the message box limit is surpassed.

newtype NonBlockingInput a Source #

A wrapper around BlockingInput with a non-blocking IsInput instance.

deliver will enqueue the message or return False immediately, if the message box already contains more messages than it's limit allows.

Instances

Instances details
IsInput NonBlockingInput Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

data WaitingBoxLimit Source #

A IsMessageBoxArg instance wrapping the BlockingBox with independently configurable timeouts for receive and deliver.

data WaitingBox a Source #

A BlockingBox an a WaitingBoxLimit for the IsMessageBox instance.

Instances

Instances details
IsMessageBox WaitingBox Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

Associated Types

type Input WaitingBox :: Type -> Type Source #

type Input WaitingBox Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

data WaitingInput a Source #

An input for a BlockingBox that will block for not much more than the given timeout when the message box is full.

Constructors

WaitingInput !Int !(BlockingInput a) 

Instances

Instances details
IsInput WaitingInput Source # 
Instance details

Defined in UnliftIO.MessageBox.Limited

Methods

deliver :: MonadUnliftIO m => WaitingInput a -> a -> m Bool Source #

deliver_ :: MonadUnliftIO m => WaitingInput a -> a -> m () Source #