Idris2Doc : System.Concurrency

System.Concurrency

(source)
Concurrency primitives, e.g. threads, mutexes, etc.

N.B.: At the moment this is pretty fundamentally tied to the Scheme RTS.
Given that different back ends will have entirely different threading
models, it might be unavoidable, but we might want to think about possible
primitives that back ends should support.

Definitions

setThreadData : HasIOio=>a->io ()
  Set the data stored in a thread's parameter to the given value.
Currently only supported under the scheme backends.

Totality: total
Visibility: export
getThreadData : HasIOio=> (a : Type) ->ioa
  Get the data stored in a thread's parameter.
Currently only supported under the scheme backends.

Totality: total
Visibility: export
dataMutex : Type
Totality: total
Visibility: export
makeMutex : HasIOio=>ioMutex
  Creates and returns a new mutex.

Totality: total
Visibility: export
mutexAcquire : HasIOio=>Mutex->io ()
  Acquires the mutex identified by `mutex`. The thread blocks until the mutex
has been acquired.

Mutexes are recursive in Posix threads terminology, which means that the
calling thread can use mutex-acquire to (re)acquire a mutex it already has.
In this case, an equal number of mutex-release calls is necessary to release
the mutex.

Totality: total
Visibility: export
mutexRelease : HasIOio=>Mutex->io ()
  Releases the mutex identified by `mutex`. Unpredictable behavior results if
the mutex is not owned by the calling thread.

Totality: total
Visibility: export
dataCondition : Type
Totality: total
Visibility: export
makeCondition : HasIOio=>ioCondition
  Creates and returns a new condition variable.

Totality: total
Visibility: export
conditionWait : HasIOio=>Condition->Mutex->io ()
  Waits up to the specified timeout for the condition identified by the
condition variable `cond`. The calling thread must have acquired the mutex
identified by `mutex` at the time `conditionWait` is called. The mutex is
released as a side effect of the call to `conditionWait`. When a thread is
later released from the condition variable by one of the procedures
described below, the mutex is reacquired and `conditionWait` returns.

Totality: total
Visibility: export
conditionWaitTimeout : HasIOio=>Condition->Mutex->Int->io ()
  Variant of `conditionWait` with a timeout in microseconds.
When the timeout expires, the thread is released, `mutex` is reacquired, and
`conditionWaitTimeout` returns.

Totality: total
Visibility: export
conditionSignal : HasIOio=>Condition->io ()
  Releases one of the threads waiting for the condition identified by `cond`.

Totality: total
Visibility: export
conditionBroadcast : HasIOio=>Condition->io ()
  Releases all of the threads waiting for the condition identified by `cond`.

Totality: total
Visibility: export
dataSemaphore : Type
Totality: total
Visibility: export
makeSemaphore : HasIOio=>Int->ioSemaphore
  Creates and returns a new semaphore with the counter initially set to `init`.

Totality: total
Visibility: export
semaphorePost : HasIOio=>Semaphore->io ()
  Increments the semaphore's internal counter.

Totality: total
Visibility: export
semaphoreWait : HasIOio=>Semaphore->io ()
  Blocks until the internal counter for semaphore sema is non-zero. When the
counter is non-zero, it is decremented and `semaphoreWait` returns.

Totality: total
Visibility: export
dataBarrier : Type
  A barrier enables multiple threads to synchronize the beginning of some
computation.

Totality: total
Visibility: export
makeBarrier : HasIOio=>Int->ioBarrier
  Creates a new barrier that can block a given number of threads.

@ numThreads the number of threads to block

Totality: total
Visibility: export
barrierWait : HasIOio=>Barrier->io ()
  Blocks the current thread until all threads have rendezvoused here.

Totality: total
Visibility: export
dataChannel : Type->Type
Totality: total
Visibility: export
makeChannel : HasIOio=>io (Channela)
  Creates and returns a new `Channel`.

The channel can be used with `channelGet` to receive a value through the
channel.
The channel can be used with `channelPut` to send a value through the
channel.

Totality: total
Visibility: export
channelGet : HasIOio=>Channela->ioa
  Blocks until a sender is ready to provide a value through `chan`. The result
is the sent value.

@ chan the channel to receive on

Totality: total
Visibility: export
channelPut : HasIOio=>Channela->a->io ()
  Puts a value on the given channel.

@ chan the `Channel` to send the value over
@ val the value to send

Totality: total
Visibility: export