Bounded is:module
The functions in this module are explict about the maximum number of
bytes they require.
Types to represent ℤ/nℤ.
ℤ/nℤ is a finite field and is defined as the set of natural number:
{0, 1, ..., n − 1}.
Searching unbounded intervals within bounded integral types for the
boundary of an upward-closed set, using a combination of exponential
and binary search.
This library provides a strict, immutable, thread-safe, single-ended,
bounded queue. When the insert limit is reached and a
cons is
attempted, this
BQueue automatically drops old entries off its
end. Thus, writes always succeed and never block.
This data structure is intended as a "sliding window" over some stream
of data, where we wish old entries to be naturally forgotten. Since
this is an immutable data structure and not a concurrent queue, we
provide instances for the usual useful typeclasses with which one can
perform analysis over the entire "window".
This module is intended to be imported qualified:
import qualified Data.Queue.Bounded as BQ
Proves a simple mutex algorithm correct up to a given bound.
Implements bounded channels. These channels differ from normal
Chans in that they are guaranteed to contain no more than a
certain number of elements. This is ideal when you may be writing to a
channel faster than you are able to read from it.
This module supports all the functions of
Control.Concurrent.Chan except
unGetChan and
dupChan, which are not supported for bounded channels.
Extra consistency: This version enforces that if thread Alice writes
e1 followed by e2 then e1 will be returned by readBoundedChan before
e2. Conversely, if thead Bob reads e1 followed by e2 then it was true
that writeBoundedChan e1 preceded writeBoundedChan e2.
Previous versions did not enforce this consistency: if
writeBoundedChan were preempted between putMVars or killThread arrived
between putMVars then it can fail. Similarly it might fail if
readBoundedChan were stopped after putMVar and before the second
takeMVar. An unlucky pattern of several such deaths might actually
break the invariants of the array in an unrecoverable way causing all
future reads and writes to block.
Implements bounded channels. These channels differ from normal
Chans in that they are guaranteed to contain no more than a
certain number of elements. This is ideal when you may be writing to a
channel faster than you are able to read from it.
This module supports all the functions of
Control.Concurrent.Chan except
unGetChan and
dupChan, which are not supported for bounded channels.
Extra consitency: This version enforces that if thread Alice writes e1
followed by e2 then e1 will be returned by readChan before e2.
Conversely, if thead Bob reads e1 followed by e2 then it was true that
writeChan e1 preceded writeChan e2.
Previous versions did not enforce this consistency: if writeChan were
preempted between putMVars or killThread arrived between putMVars then
it can fail. Similarly it might fail if readChan were stopped after
putMVar and before the second takeMVar. An unlucky pattern of several
such deaths might actually break the invariants of the array in an
unrecoverable way causing all future reads and writes to block.
This module wraps Control.Concurrent.Thread.Group and provides a
bounded version of ThreadGroup, mainly
BoundedThreadGroup.
In addition to the functionality of
ThreadGroup,
BoundedThreadGroup will block creation of threads until there
fewer than the given max size.