io.reactors

Reactor

trait Reactor[T] extends AnyRef

A reactor is a basic unit of concurrency.

A concurrent program in the Reactors framework is composed of multiple reactors, which execute concurrently, and in isolation. The only way they can communicate is by exchanging events using entities called *channels*.

A Reactor[T] object accepts events of type T on its input channel. One reactor can propagate events concurrently to other reactors. Event streams cannot be shared between reactors -- it is an error to use an event stream originating in one reactor in some different reactor.

Reactors are defined by extending the Reactor trait. The events passed to reactors can be subscribed to using their main.events stream. Here is an example:

class MyPrinter extends Reactor[String] {
  main.events onEvent {
    e => println(e)
  }
}

Separate reactor instances that exist at runtime are created using reactor systems. Each reactor belongs to a specific reactor system. Usually there is a single reactor system within a single program instance. Here is an example:

val reactorSystem = ReactorSystem.default("MyReactorSystem")
val channel = reactorSystem.spawn(Proto[MyPrinter])

Creating a reactor returns its channel. Events can be sent to a channel using the ! method:

channel ! "Hi!" // eventually, this is printed by `MyPrinter`

To stop, a reactor must seal its main channel. The following reactor seals its main channel after receiving the first event:

class MyPrinter extends Reactor[String] {
  main.events onEvent {
    e =>
    println(e)
    main.seal()
  }
}

Reactors also receive special SysEvent events on the internal.events stream.

T

the type of events, which this reactor produces

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Reactor
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

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

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

    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from Reactor[T] to any2stringadd[Reactor[T]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Reactor[T], B)

    Implicit information
    This member is added by an implicit conversion from Reactor[T] to ArrowAssoc[Reactor[T]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def ensuring(cond: (Reactor[T]) ⇒ Boolean, msg: ⇒ Any): Reactor[T]

    Implicit information
    This member is added by an implicit conversion from Reactor[T] to Ensuring[Reactor[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  9. def ensuring(cond: (Reactor[T]) ⇒ Boolean): Reactor[T]

    Implicit information
    This member is added by an implicit conversion from Reactor[T] to Ensuring[Reactor[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: Boolean, msg: ⇒ Any): Reactor[T]

    Implicit information
    This member is added by an implicit conversion from Reactor[T] to Ensuring[Reactor[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean): Reactor[T]

    Implicit information
    This member is added by an implicit conversion from Reactor[T] to Ensuring[Reactor[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. final def eq(arg0: AnyRef): Boolean

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from Reactor[T] to StringFormat[Reactor[T]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  16. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

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

    Definition Classes
    Any
  19. final def main: Connector[T]

    The main connector of this reactor.

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

    Definition Classes
    AnyRef
  21. final def notify(): Unit

    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  24. final def sysEvents: Events[SysEvent]

    The system event stream of this isolate.

  25. final def system: ReactorSystem

    The reactor system of this reactor.

  26. def toString(): String

    Definition Classes
    AnyRef → Any
  27. final def uid: Long

    The unique id of this reactor.

    The unique id of this reactor.

    returns

    the unique id, assigned only to this reactor

  28. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. def [B](y: B): (Reactor[T], B)

    Implicit information
    This member is added by an implicit conversion from Reactor[T] to ArrowAssoc[Reactor[T]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from Reactor[T] to any2stringadd[Reactor[T]]

Inherited by implicit conversion StringFormat from Reactor[T] to StringFormat[Reactor[T]]

Inherited by implicit conversion Ensuring from Reactor[T] to Ensuring[Reactor[T]]

Inherited by implicit conversion ArrowAssoc from Reactor[T] to ArrowAssoc[Reactor[T]]

Ungrouped