<Description>
<Ref Func="CreateChannel"/> returns a FIFO communication channel that can be used to exchange information between threads. Its
optional argument is a capacity (positive integer). If insufficient resources are available to create a channel, it
returns -1. If the capacity is not a positive integer, an error will be raised.
<P/>
If a capacity is not provided, by default the channel can hold an indefinite number of objects. Otherwise, attempts to
store objects in the channel beyond its capacity will block.
<Description>
<Ref Func="SendChannel"/> accepts two arguments, a channel object returned by <Ref Func="CreateChannel"/>, and an arbitrary GAP
object. It stores <A>obj</A> in <A>channel</A>. If <A>channel</A> has a finite capacity and is currently full, then
<Ref Func="SendChannel"/> will block until at least one element has been removed from the channel, e.g. using <Ref
Func="ReceiveChannel"/>.
<P/>
<Ref Func="SendChannel"/> performs automatic region migration for thread-local objects. If <A>obj</A> is thread-local for the
current thread, it will be migrated (along with all subobjects contained in the same region) to the receiving
thread's thread-local data space. In between sending and receiving, <A>obj</A> cannot be accessed by either thread.
<P/>
This example demonstrates sending messages across a channel.
<Description>
<Ref Func="TransmitChannel"/> is identical to <Ref Func="SendChannel"/>,
except that it does not perform automatic region migration of
thread-local objects.
<Description>
<Ref Func="TrySendChannel"/> is identical to <Ref Func="SendChannel"/>,
except that it returns if the channel is full instead of
blocking. It returns true if the send was successful and false otherwise.
<Description>
<Ref Func="TryTransmitChannel"/> is identical to <Ref Func="TrySendChannel"/>,
except that it does not perform automatic region migration of thread-local objects.
</Description>
</ManSection>
<Description>
<Ref Func="ReceiveChannel"/> is used to retrieve elements from a channel.
If <A>channel</A> is empty, the call will block until an element has been
added to the channel via <Ref Func="SendChannel"/> or a similar primitive.
<P/>
See <Ref Func="SendChannel"/> for an example.
</Description>
</ManSection>
<Description>
<Ref Func="TryReceiveChannel"/>, like <Ref Func="ReceiveChannel"/>,
attempts to retrieve an object from <A>channel</A>. If it does not
succeed, however, it will return <A>default</A> rather than blocking.
<Description>
<Ref Func="MultiSendChannel"/> allows the sending of all the objects contained in the list <A>list</A> to <A>channel</A> as a
single operation. The list must be dense and is not modified by the call. The function will send elements starting at
index 1 until all elements have been sent. If a channel with finite capacity is full, then the operation will block
until all elements can be sent.
<P/>
The operation is designed to be more efficient than sending all elements individually via <Ref Func="SendChannel"/> by
minimizing potentially expensive concurrency operations.
<P/>
See <Ref Func="MultiReceiveChannel"/> for an example.
</Description>
</ManSection>
<Description>
<Ref Func="TryMultiSendChannel"/> operates like <Ref Func="MultiSendChannel"/>,
except that it returns rather than blocking if it
cannot send any more elements if the channel is full.
It returns the number of elements it has sent. If <A>channel</A>
does not have finite capacity, <Ref Func="TryMultiSendChannel"/>
will always send all elements in the list.
</Description>
</ManSection>
<Description>
<Ref Func="MultiReceiveChannel"/> is the receiving counterpart to
<Ref Func="MultiSendChannel"/>.It will try to receive up to
<A>amount</A> objects from <A>channel</A>. If the channel contains less
than <A>amount</A> objects, it will return rather than blocking.
<P/>
The function returns a list of all the objects received.
<ManSection>
<Func Name="ReceiveAnyChannel" Arg='channel_1, ..., channel_n'/>
<Func Name="ReceiveAnyChannel" Arg='channel_list' Label="for a list of channels"/>
<Description>
<Ref Func="ReceiveAnyChannel"/> is a multiplexing variant of<Ref Func="ReceiveChannel"/>.
It blocks until at least one of the channels provided contains an object.
It will then retrieve that object from the channel and return it.
<ManSection>
<Func Name="ReceiveAnyChannelWithIndex" Arg='channel_1, ..., channel_n'/>
<Func Name="ReceiveAnyChannelWithIndex" Arg='channel_list' Label="for a list of channels"/>
<Description>
<Ref Func="ReceiveAnyChannelWithIndex"/> works like <Ref Func="ReceiveAnyChannel"/>,
except that it returns a list with two elements, the first being the object
being received, the second being the number of the channel from which the
object has been retrieved.
<Description>
<Ref Func="TallyChannel"/> returns the number of objects that a channel contains. This number can increase or decrease, as data
is sent to or received from this channel. Send operations will only ever increase and receive operations will only ever
decrease this count. Thus, if there is only one thread receiving data from the channel, it can use the result as a lower
bound for the number of elements that will be available in the channel.
<Description>
<Ref Func="InspectChannel"/> returns a list of the objects that a channel contains. Note that objects that are not in the
shared, public, or read-only region will be temporarily stored in the so-called limbo region while in transit and will
be inaccessible through normal means until they have been received.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.