ox.channels
Members list
Type members
Classlikes
Channel is a thread-safe data structure which exposes three basic operations:
Channel is a thread-safe data structure which exposes three basic operations:
- send-ing a value to the channel. Values can't be
null
. - receive-ing a value from the channel
- closing the channel using done or error
There are three channel flavors:
- rendezvous channels, where senders and receivers must meet to exchange values
- buffered channels, where a given number of sent values might be buffered, before subsequent
send
s block - unlimited channels, where an unlimited number of values might be buffered, hence
send
never blocks
Channels can be created using the channel's companion object. When no arguments are given, a rendezvous channel is created, while a buffered channel can be created by providing a positive integer to the Channel.apply method. A rendezvous channel behaves like a buffered channel with buffer size 0. An unlimited channel can be created using Channel.unlimited.
In a rendezvous channel, senders and receivers block, until a matching party arrives (unless one is already waiting). Similarly, buffered channels block if the buffer is full (in case of senders), or in case of receivers, if the buffer is empty and there are no waiting senders.
All blocking operations behave properly upon interruption.
Channels might be closed, either because no more values will be produced by the source (using done), or because there was an error while producing or processing the received values (using error).
After closing, no more values can be sent to the channel. If the channel is "done", any pending sends will be completed normally. If the channel is in an "error" state, pending sends will be interrupted and will return with the reason for the closure.
In case the channel is closed, one of the ChannelClosed values are returned. These can be converted to an exception by calling orThrow on a result which includes ChannelClosed as one of the components of the union type.
Type parameters
- T
-
The type of the values processed by the channel.
Attributes
- Companion
- object
- Supertypes
Returned by channel methods (e.g. Source.receive, Sink.send, select) when the channel is closed.
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
ChannelClosed.type
A default clause, which will be chosen if no other clause can be selected immediately, during a select call.
A default clause, which will be chosen if no other clause can be selected immediately, during a select call.
There should be at most one default clause, and it should always come last in the list of clauses.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait SelectClause[T]class Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait SelectResult[T]class Objecttrait Matchableclass AnyShow all
A clause to use as part of select. Clauses can be created having a channel instance, using Source.receiveClause and Sink.sendClause.
A clause to use as part of select. Clauses can be created having a channel instance, using Source.receiveClause and Sink.sendClause.
A clause instance is immutable and can be reused in multiple select calls.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Results of a select call, when clauses are passed (instead of a number of Sources). Each result corresponds to a clause, and can be pattern-matched (using a path-dependent type)) to inspect which clause was selected.
A channel source, which can be used to receive values from the channel. See Channel for more details.
Various operations which allow creating Source instances.
Various operations which allow creating Source instances.
Some need to be run within a concurrency scope, such as supervised.
Attributes
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object Source.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
StageCapacity.type
Types
Value members
Concrete methods
Attributes
- See also
Attributes
- See also
Attributes
- See also
Attributes
- See also
Select exactly one clause to complete. Each clause should be created for a different channel.
Select exactly one clause to complete. Each clause should be created for a different channel.
If a couple of the clauses can be completed immediately, the select is biased towards the clauses that appear first.
If no clauses are given, or all clauses become filtered out, returns ChannelClosed.Done.
If a receive clause is selected for a channel that is done, select restarts, unless the clause is created with Source.receiveOrDoneClause.
Value parameters
- clauses
-
The clauses, from which one will be selected.
Attributes
- Returns
-
The result returned by the selected clause, wrapped with SelectResult, or a ChannelClosed, when any of the channels is closed (done or in error), and the select doesn't restart.
Extensions
Extensions
Throw a ChannelClosedException if the provided value represents a closed channel (one of ChannelClosed values).
Throw a ChannelClosedException if the provided value represents a closed channel (one of ChannelClosed values).