Module

Concurrent.BoundedQueue

A concurrent FIFO data structure with bounded capacity.

This datastructure is useful in various consumer/producer situations.

#new

new :: forall a. Int -> Aff (BoundedQueue a)

Creates a new BoundedQueue with the given capacity,

#write

write :: forall a. BoundedQueue a -> a -> Aff Unit

Writes an element to the given queue. Will block if the queue is full until someone reads from it.

#read

read :: forall a. BoundedQueue a -> Aff a

Reads an element from the given queue, will block if the queue is empty, until someone writes to it.

#isEmpty

isEmpty :: forall a. BoundedQueue a -> Aff Boolean

Checks whether the given queue is empty. Never blocks.

#tryRead

tryRead :: forall a. BoundedQueue a -> Aff (Maybe a)

Attempts to read an element from the given queue. If the queue is empty, returns Nothing.

Careful! If other readers are blocked on the queue tryRead will also block.

#tryWrite

tryWrite :: forall a. BoundedQueue a -> a -> Aff Boolean

Attempts to write an element into the given queue. If the queue is full, returns false otherwise true.

Careful! If other writers are blocked on the queue tryWrite will also block.

Re-exports from Concurrent.BoundedQueue.Internal

#BoundedQueue

newtype BoundedQueue a

Modules