Module
Concurrent.BoundedQueue
- Package
- purescript-concurrent-queues
- Repository
- slamdata/purescript-concurrent-queues
A concurrent FIFO data structure with bounded capacity.
This datastructure is useful in various consumer/producer situations.
#BoundedQueue Source
newtype BoundedQueue a
#new Source
new :: forall eff a. Int -> Aff (avar :: AVAR | eff) (BoundedQueue a)
Creates a new BoundedQueue
with the given capacity,
#write Source
write :: forall eff a. BoundedQueue a -> a -> Aff (avar :: AVAR | eff) Unit
Writes an element to the given queue. Will block if the queue is full until someone reads from it.
#read Source
read :: forall eff a. BoundedQueue a -> Aff (avar :: AVAR | eff) a
Reads an element from the given queue, will block if the queue is empty, until someone writes to it.
#isEmpty Source
isEmpty :: forall eff a. BoundedQueue a -> Aff (avar :: AVAR | eff) Boolean
Checks whether the given queue is empty. Never blocks.