ox.channels

package ox.channels

Members list

Type members

Classlikes

object Actor

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Actor.type
class ActorRef[T](c: Sink[T => Unit])

Attributes

Supertypes
class Object
trait Matchable
class Any
class Channel[T] extends Source[T], Sink[T]

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 sends 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 (StageCapacity.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 SourceTextOps[T]
trait SourceIOOps[T]
trait SourceDrainOps[T]
trait SourceOps[T]
class Object
trait Matchable
class Any
Show all
object Channel

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Channel.type
sealed trait ChannelClosed

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 Object
trait Matchable
class Any
Known subtypes
object Done
class Error
object ChannelClosed

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
enum ChannelClosedException(cause: Option[Throwable]) extends Exception

Attributes

Supertypes
trait Enum
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
case Error
case Done

Extension methods on union types which includes ChannelClosed.

Extension methods on union types which includes ChannelClosed.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class Default[T](value: T) extends SelectClause[T]

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 Serializable
trait Product
trait Equals
trait SelectClause[T]
class Object
trait Matchable
class Any
Show all
case class DefaultResult[T](value: T) extends SelectResult[T]

The result returned in case a Default clause was selected in select.

The result returned in case a Default clause was selected in select.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SelectResult[T]
class Object
trait Matchable
class Any
Show all
sealed trait SelectClause[+T]

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 Object
trait Matchable
class Any
Known subtypes
class Receive
class Send
class Default[T]
sealed trait SelectResult[+T]

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.

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.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Received
class Sent
class DefaultResult[T]
trait Sink[-T]

A channel sink, which can be used to send values to the channel. See Channel for more details.

A channel sink, which can be used to send values to the channel. See Channel for more details.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Channel[T]
trait Source[+T] extends SourceOps[T], SourceDrainOps[T], SourceIOOps[T], SourceTextOps[T]

A channel source, which can be used to receive values from the channel. See Channel for more details.

A channel source, which can be used to receive values from the channel. See Channel for more details.

Attributes

Companion
object
Supertypes
trait SourceTextOps[T]
trait SourceIOOps[T]
trait SourceDrainOps[T]
trait SourceOps[T]
class Object
trait Matchable
class Any
Show all
Known subtypes
class Channel[T]

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

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Source.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Source

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Source
trait SourceDrainOps[+T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Source[T]
class Channel[T]
Self type
Source[T]
trait SourceIOOps[+T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Source[T]
class Channel[T]
Self type
Source[T]
trait SourceOps[+T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Source[T]
class Channel[T]
Self type
Source[T]
trait SourceTextOps[+T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Source[T]
class Channel[T]
Self type
Source[T]
object StageCapacity

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Types

opaque type StageCapacity

Used to determine the capacity of internal processing stages, when new channels are created by channel-transforming operations, such as Source.map. If not in scope, the default of 16 is used.

Used to determine the capacity of internal processing stages, when new channels are created by channel-transforming operations, such as Source.map. If not in scope, the default of 16 is used.

Attributes

Value members

Concrete methods

def select(clause1: SelectClause[_], clause2: SelectClause[_]): clause1.Result | clause2.Result

Attributes

See also
def select(clause1: SelectClause[_], clause2: SelectClause[_], clause3: SelectClause[_]): clause1.Result | clause2.Result | clause3.Result

Attributes

See also
def select(clause1: SelectClause[_], clause2: SelectClause[_], clause3: SelectClause[_], clause4: SelectClause[_]): clause1.Result | clause2.Result | clause3.Result | clause4.Result

Attributes

See also
def select(clause1: SelectClause[_], clause2: SelectClause[_], clause3: SelectClause[_], clause4: SelectClause[_], clause5: SelectClause[_]): clause1.Result | clause2.Result | clause3.Result | clause4.Result | clause5.Result

Attributes

See also
def select[T](clauses: List[SelectClause[T]]): SelectResult[T]

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).

def select[T1, T2](source1: Source[T1], source2: Source[T2]): T1 | T2

Attributes

See also
def select[T1, T2, T3](source1: Source[T1], source2: Source[T2], source3: Source[T3]): T1 | T2 | T3

Attributes

See also
def select[T1, T2, T3, T4](source1: Source[T1], source2: Source[T2], source3: Source[T3], source4: Source[T4]): T1 | T2 | T3 | T4

Attributes

See also
def select[T1, T2, T3, T4, T5](source1: Source[T1], source2: Source[T2], source3: Source[T3], source4: Source[T4], source5: Source[T5]): T1 | T2 | T3 | T4 | T5

Attributes

See also
def select[T](sources: List[Source[T]])(using DummyImplicit): T | ChannelClosed

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).

def selectOrClosed(clause1: SelectClause[_], clause2: SelectClause[_]): clause1.Result | clause2.Result | ChannelClosed

Attributes

See also
def selectOrClosed(clause1: SelectClause[_], clause2: SelectClause[_], clause3: SelectClause[_]): clause1.Result | clause2.Result | clause3.Result | ChannelClosed

Attributes

See also
def selectOrClosed(clause1: SelectClause[_], clause2: SelectClause[_], clause3: SelectClause[_], clause4: SelectClause[_]): clause1.Result | clause2.Result | clause3.Result | clause4.Result | ChannelClosed

Attributes

See also
def selectOrClosed(clause1: SelectClause[_], clause2: SelectClause[_], clause3: SelectClause[_], clause4: SelectClause[_], clause5: SelectClause[_]): clause1.Result | clause2.Result | clause3.Result | clause4.Result | clause5.Result | ChannelClosed

Attributes

See also
def selectOrClosed[T](clauses: List[SelectClause[T]]): SelectResult[T] | ChannelClosed

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).

def selectOrClosed[T1, T2](source1: Source[T1], source2: Source[T2]): T1 | T2 | ChannelClosed

Attributes

See also
def selectOrClosed[T1, T2, T3](source1: Source[T1], source2: Source[T2], source3: Source[T3]): T1 | T2 | T3 | ChannelClosed

Attributes

See also
def selectOrClosed[T1, T2, T3, T4](source1: Source[T1], source2: Source[T2], source3: Source[T3], source4: Source[T4]): T1 | T2 | T3 | T4 | ChannelClosed

Attributes

See also
def selectOrClosed[T1, T2, T3, T4, T5](source1: Source[T1], source2: Source[T2], source3: Source[T3], source4: Source[T4], source5: Source[T5]): T1 | T2 | T3 | T4 | T5 | ChannelClosed

Attributes

See also
def selectOrClosed[T](sources: List[Source[T]])(using DummyImplicit): T | ChannelClosed

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).