Class/Object

molecule.channel

RIChan

Related Docs: object RIChan | package channel

Permalink

abstract class RIChan[+A] extends IChan[A]

"Result", "reply" or "response" input channel interface.

Result channels are system-level input channels that deliver only a single message followed by the EOS. They obey channel semantics in that they cannot be read concurrently and they deliver messages only once - a result channel that is read a second time will deliver the EOS signal.

The computations associated to a result channel, and hence transformations like map or flatMap, are only fired lazyliy when a process attempts to read the result from the channel. Transformations featuring side-effects can be executed even if no one is interested in the result by calling the fire() method. This method returns a new result channel that consumes the result after the transformations have been applied and then stores it internally in an intermediate buffer such that it can still be consumed later.

In all situations, the continuations or the transformation functions applied to a result channel are carried by default inside the thread that produces the result. To improve reactiveness and/or isolate concurrent computations from each other, it is prefereable to free as soon as possible the thread that produces results and offload the computation of transformations to the thread that consumes the result. The dispatchTo method, if it is called immediately after a future is created, will dipatch any subsequent continuation or transformation to the standard juc.Executor that it is passed as parameter. For example, this could be either a molecule.platform.Platform or a molecule.platform.UThread, which both inherit from the Executor interface. In the first case, continuations will be carried inside a new user-level thread created by the target platform. In the second case, the continuations will be pinned down to an existing user-level thread.

Note that in case a message is pure, the result of a result channel can be cached for multiple (sequential) reads using the cache() method. Alternatively, for interoperability with Java, a result can also be wrapped inside a standard juc.Future by invoking the future() method on result channels (this method is provided via an implicit conversion to RIChanWithFuture in the companion object).

A

the type of the message returned by the channel

Self Type
RIChan[A]
Linear Supertypes
IChan[A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. RIChan
  2. IChan
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new RIChan()

    Permalink

Abstract Value Members

  1. abstract def poison(signal: Signal): Unit

    Permalink

    Poison this channel and any segment it may have buffered.

    Poison this channel and any segment it may have buffered.

    signal

    the poison signal.

    returns

    Unit

    Definition Classes
    IChan
  2. abstract def read(success: (A) ⇒ Unit, failure: (Signal) ⇒ Unit): Unit

    Permalink

    Read a result asynchronously using continuations for success and failure cases.

    Read a result asynchronously using continuations for success and failure cases.

    success

    continuation invoked in case of success.

    failure

    continuation invoked in case of failure.

    returns

    unit

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def and[B](other: RIChan[B])(implicit ma: Message[A], mb: Message[B]): RIChan[(A, B)]

    Permalink

    Return both the result of this channel and the one of another channel.

    Return both the result of this channel and the one of another channel.

    The new channel created succeeds with both successful results or fails as soon as one of the RIChan fails.

    other

    the other result channel.

    returns

    a pair containing the the result of this channel and the other one.

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def cache()(implicit ma: Message[A]): RIChan[A]

    Permalink

    Cache the message received on the underlying channel such that the same result can be read multiple times (sequentially).

    Cache the message received on the underlying channel such that the same result can be read multiple times (sequentially).

    Important note: Caching messages violates uniqueness of references. Therefore, one must ensure that only "Pure" messages are cached using this mechanism or be careful when poisoning the resulting channel.

    returns

    a result channel that can be read multiple times.

  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def dispatchTo(executor: Executor): RIChan[A]

    Permalink

    Creates a new result channel whose transformations will be executed in the context of another executor.

    Creates a new result channel whose transformations will be executed in the context of another executor. The executor might be a Platform or a user-level thread (UThread), which both implement the juc.Executor interface.

    executor

    the executor that will execute the subsequent transformations.

    returns

    a result channel whose continuations will be invoked in the context of the executor.

  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def fire()(implicit m: Message[A]): RIChan[A]

    Permalink

    Execute all the transformations stacked up on this result channel, and then cache the result into a new result channel.

    Execute all the transformations stacked up on this result channel, and then cache the result into a new result channel. This method ensures that all side-effects performed by transformations applied on this result channel are executed, even if this future is not consumed. Note that it is useless to invoke this method if transformations have no side-effects.

    returns

    a RIChan.

  13. def flatMap[B](f: (A) ⇒ RIChan[B]): RIChan[B]

    Permalink

    Schedule another asynchronous continuation, which is a function of the result of this channel.

    Schedule another asynchronous continuation, which is a function of the result of this channel.

    The thread that executes the function is defined by how this result channel was created.

    f

    the function that creates a new asynchronous computation using the success result of this channel interface.

    returns

    a new channel interface obtained by chaining a new computation after this result is available.

  14. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  15. def get_!(): A

    Permalink

    BLOCK the native thread until a result is available.

    BLOCK the native thread until a result is available.

    All transformations applied before the result channel (or after a FutureRIChan) was was created will be applied in the same native thread than the one that blocks on this result.

    returns

    the result.

  16. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  18. def map[B](f: (A) ⇒ B): RIChan[B]

    Permalink

    Map a function to the result of this channel interface.

    Map a function to the result of this channel interface.

    The thread that executes the function is defined by how this result channel was created.

    f

    the function applied to the result produced by this channel in case of success.

    returns

    A new channel interface obtained by applying f to the result of this channel interface.

  19. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. def onComplete(success: (A) ⇒ Unit, failure: (Signal) ⇒ Unit): Unit

    Permalink

    React to a result asynchronously using continuations for success and failure cases.

    React to a result asynchronously using continuations for success and failure cases.

    success

    continuation invoked in case of success.

    failure

    continuation invoked in case of failure.

    returns

    unit

  23. def or[B](other: RIChan[B])(implicit ma: Message[A], mb: Message[B]): RIChan[Either[A, B]]

    Permalink

    Choose the first result between the result of this channel and the one of another channel.

    Choose the first result between the result of this channel and the one of another channel.

    The new result channel created succeeds with the first successful result returned by either this channel or the other channel. It fails only if both channels fail. The other result channel will be automatically poisoned once a result becomes available.

    other

    the other result channel.

    returns

    either the result of this channel or the result of the other one.

  24. def orCatch[B >: A](recover: PartialFunction[Signal, RIChan[B]]): RIChan[B]

    Permalink

    Fallback to an alternative result channel if this channel raises a signal instead of returning a result.

    Fallback to an alternative result channel if this channel raises a signal instead of returning a result.

    recover

    the partial function invoked if a signal is raised.

    returns

    a new result channel.

  25. def read(k: (Seg[A], IChan[A]) ⇒ Unit): Unit

    Permalink

    Read a segment from this channel.

    Read a segment from this channel.

    k

    the continuation taking the last segment read as parameter and the seed on which to read subsequent segments.

    returns

    Unit

    Definition Classes
    RIChanIChan
  26. def readWithin(delay: Long, unit: TimeUnit)(implicit ma: Message[A]): RIChan[Option[A]]

    Permalink

    Read the result of a result channel within the specified timeout.

    Read the result of a result channel within the specified timeout. If the result is no available within the specified timeout, this channel will be automatically poisoned.

    delay

    the time from now to delay execution.

    unit

    the time unit of the delay parameter.

    returns

    some result if the result becomes available before the timeout, else none.

  27. def select[B](other: RIChan[B])(implicit ma: Message[A], mb: Message[B]): RIChan[Either[(A, RIChan[B]), (B, RIChan[A])]]

    Permalink

    Choose the first result between the result of this channel and the one of another channel.

    Choose the first result between the result of this channel and the one of another channel.

    The new result channel created succeeds with the first successful result returned by either this channel or the other channel. It fails only if both channels fail. Whenever one of the result channels succeeds, the other result channel is returned with the result such that one can attempt to retrieve the other result a second time later.

    other

    the other result channel.

    returns

    either the result of this channel or the result of the other one.

  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  29. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  30. def tryReadWithin(delay: Long, unit: TimeUnit)(implicit ma: Message[A]): RIChan[Either[RIChan[A], A]]

    Permalink

    Try to read the result of a result channel within the specified timeout.

    Try to read the result of a result channel within the specified timeout. If the result is not available before the specified timeout, a new result channel is returned, which can be used to retrieve the result again later.

    delay

    the time from now to delay execution.

    unit

    the time unit of the delay parameter.

    returns

    Either the result if it becomes available before the timeout, or a new result channel, which can be read a second time later.

  31. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from IChan[A]

Inherited from AnyRef

Inherited from Any

Ungrouped