ox.channels
Members list
Type members
Classlikes
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
BufferCapacity.type
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. A rendezvous channel is created using Channel.rendezvous. A buffered channel can be created either with a given capacity - by providing a positive integer to the Channel.buffered method - or with the default capacity (BufferCapacity.default) using Channel.bufferedDefault . 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, a ChannelClosedException is thrown. Alternatively, you can use the orClosed
method variants (e.g. sendOrClosed, receiveOrClosed), which don't throw exceptions, but return a union type which includes one of ChannelClosed values. Such a union type can be further converted to an exception, Either or Try using one of the extension methods in ChannelClosedUnion.
Type parameters
- T
-
The type of the values processed by the channel.
Attributes
- Companion
- object
- Supertypes
-
trait Sink[T]trait Source[T]trait SourceDrainOps[T]trait SourceOps[T]class Objecttrait Matchableclass AnyShow all
Returned by channel methods (e.g. Source.receiveOrClosed, Sink.sendOrClosed, selectOrClosed) when the channel is closed.
Returned by channel methods (e.g. Source.receiveOrClosed, Sink.sendOrClosed, selectOrClosed) when the channel is closed.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
ChannelClosed.type
Extension methods on union types which includes ChannelClosed.
Extension methods on union types which includes ChannelClosed.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ChannelClosedUnion.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.
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
Types
Used to determine the capacity of buffers, when new channels are created by channel or flow-transforming operations, such as Source.map, Flow.async, Flow.runToChannel. If not in scope, the default of 16 is used.
Used to determine the capacity of buffers, when new channels are created by channel or flow-transforming operations, such as Source.map, Flow.async, Flow.runToChannel. If not in scope, the default of 16 is used.
Attributes
Value members
Concrete methods
Fork the given computation, propagating any exceptions to the given sink. The propagated exceptions are not rethrown.
Fork the given computation, propagating any exceptions to the given sink. The propagated exceptions are not rethrown.
Designed to be used in stream operators.
Attributes
- See also
-
ADR#1, ADR#3, implementation note in SourceOps.
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. Clauses can be created using Source.receiveClause, Sink.sendClause and Default.
Select exactly one clause to complete. Each clause should be created for a different channel. Clauses can be created using Source.receiveClause, Sink.sendClause and Default.
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, returns ChannelClosed.Done.
For a variant which doesn't throw exceptions when any of the channels is closed, use selectOrClosed.
Value parameters
- clauses
-
The clauses, from which one will be selected.
Attributes
- Returns
-
The result returned by the selected clause, wrapped with SelectResult.
- Throws
-
ChannelClosedException
When any of the channels is closed (done or in error).
Attributes
- See also
Attributes
- See also
Attributes
- See also
Select exactly one source, from which to receive a value. Sources should not repeat. Clauses can be created using Source.receiveClause, Sink.sendClause and Default.
Select exactly one source, from which to receive a value. Sources should not repeat. Clauses can be created using Source.receiveClause, Sink.sendClause and Default.
If a couple of the sources have values which can be received immediately, the select is biased towards the source that appears first.
If no sources are given, returns ChannelClosed.Done.
For a variant which doesn't throw exceptions when any of the channels is closed, use selectOrClosed.
Value parameters
- sources
-
The sources, from which a value will be received.
Attributes
- Returns
-
The value received from the selected source.
- Throws
-
ChannelClosedException
When any of the channels is closed (done or in error).
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. Clauses can be created using Source.receiveClause, Sink.sendClause and Default.
Select exactly one clause to complete. Each clause should be created for a different channel. Clauses can be created using Source.receiveClause, Sink.sendClause and Default.
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, returns ChannelClosed.Done.
For a variant which throws exceptions when any of the channels is closed, use select.
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).
Attributes
- See also
Attributes
- See also
Attributes
- See also
Attributes
- See also
Select exactly one source, from which to receive a value. Sources should not repeat. Clauses can be created using Source.receiveClause, Sink.sendClause and Default.
Select exactly one source, from which to receive a value. Sources should not repeat. Clauses can be created using Source.receiveClause, Sink.sendClause and Default.
If a couple of the sources have values which can be received immediately, the select is biased towards the source that appears first.
If no sources are given, returns ChannelClosed.Done.
For a variant which throws exceptions when any of the channels is closed, use select.
Value parameters
- sources
-
The sources, from which a value will be received.
Attributes
- Returns
-
The value received from the selected source, or a ChannelClosed, when any of the channels is closed (done or in error).