Trait/Object

io.reactors

Reactor

Related Docs: object Reactor | package reactors

Permalink

trait Reactor[T] extends Reflectable

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 sysEvents stream.

T

the type of events, which this reactor produces

Linear Supertypes
Reflectable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Reactor
  2. Reflectable
  3. AnyRef
  4. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

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

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

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

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

    Permalink
    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

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

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

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

    Permalink
    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]

    Permalink
    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]

    Permalink
    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]

    Permalink
    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

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

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

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

    Permalink
    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[_]

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

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

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

    Permalink

    The main connector of this reactor.

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

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

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

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

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

    Permalink

    The system event stream of this reactor.

  25. final def system: ReactorSystem

    Permalink

    The reactor system of this reactor.

  26. def toString(): String

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

    Permalink

    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

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

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

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

    Permalink
    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 Reflectable

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