Packages

  • package root
    Definition Classes
    root
  • package gopher

    Provides scala API for 'go-like' CSP channels.

    Provides scala API for 'go-like' CSP channels.

    Overview

    see readme for quick introduction.

    Usage

    At first you must receive gopherApi as Akka extension:

    import gopher._
    
    .....
    val gopherApi = Gopher(actorSystem)

    Then you can use CPS channels with blocling operations inside go clauses:

    val channel = gopherApi.makeChannel[Long]
    val n = 10000
    val producer = go {
     @volatile var(x,y) = (0L,1L)
     for( s <- gopherApi.select.forever) {
       case z: channel.write if (z==x) =>
                  x = y
                  y = x+z
                  if (x > n) {
                     channel.close
                     implicitly[FlowTermination[Unit]].doExit()
                  }
     }
    }
    val consumer = for((c,i) <- channel.zip(1 to n)) {
       Console.println(s"fib(${i})=${c}")
    }
    Await.ready(consumer, 10 seconds)

    and defer/recover in go/goScope

    goScope{
      val f = openFile(myFileName)
      defer{
        if (! recover{case ex:FileNotFoundException => Console.println("invalid fname")}) {
           f.close()
        }
      }
    }
    Definition Classes
    root
    See also

    gopher.GopherAPI

    gopher.channels.Channel

    gopher.channels.Input

    gopher.channels.Output

    gopher.channels.SelectorBuilder

    gopher.channels.SelectFactory

  • package channels

    Core entity is Continuated which provide iteratee-like structure for reading and writing.

    Overview

    • Input and Output provide callback-based interfaces for input/output facilities.
    • Channel provide implementation for asynchronics channels processing inside JVM.
    • SelectorBuilder is a way to create selectors.

    Internals

    Core entity is Continuated which provide iteratee-like structure for reading and writing. Instance of Continuated represent one step of computations and leave in queue inside ChannelProcessor or ChannelActor Selector transform Continuated to executed exclusive with each other within one selector. Also we have IdleDetector which determinate idle selectors and activer appropriative actions.

    Definition Classes
    gopher
  • trait Input[A] extends GopherAPIProvider

    Entity, from which we can read objects of type A.

    Entity, from which we can read objects of type A.

    Definition Classes
    channels
  • Filtered
  • FutureMapped
  • Mapped
  • Read
c

gopher.channels.Input

FutureMapped

class FutureMapped[B] extends Input[B]

Linear Supertypes
Input[B], GopherAPIProvider, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. FutureMapped
  2. Input
  3. GopherAPIProvider
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new FutureMapped(g: (A) => Future[B])

Type Members

  1. class Filtered extends Input[A]
    Definition Classes
    Input
  2. class FutureMapped[B] extends Input[B]
    Definition Classes
    Input
  3. type <~ = B
    Definition Classes
    Input
  4. type read = B
    Definition Classes
    Input
  5. class Mapped[B] extends Input[B]
    Definition Classes
    Input
  6. case class Read(value: A) extends Product with Serializable
    Definition Classes
    Input

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. macro def ?: B

    synonym for read.

    synonym for read.

    Definition Classes
    Input
  5. macro def afold[S, B](s0: S)(f: (S, B) => S): Future[S]

    async incarnation of fold.

    async incarnation of fold. Fold return future, which successed when channel is closed. Operations withing fold applyed on result on each other, starting with s0. val fsum = ch.afold(0){ (s, n) => s+n } Here in fsum will be future with value: sum of all elements in channel until one has been closed.

    Definition Classes
    Input
  6. def afoldAsync[S, B](s0: S)(f: (S, B) => Future[S])(implicit ec: ExecutionContext): Future[S]
    Definition Classes
    Input
  7. def afoldSync[S, B](s0: S)(f: (S, B) => S): Future[S]
    Definition Classes
    Input
  8. macro def aforeach(f: (B) => Unit): Future[Unit]
    Definition Classes
    Input
  9. def amap[B](g: (B) => Future[B]): Input[B]
    Definition Classes
    Input
  10. def api: GopherAPI

    instance of gopher API

    instance of gopher API

    Definition Classes
    FutureMappedInputGopherAPIProvider
  11. def append(other: Input[B]): Input[B]

    when the first channel is exhaused, read from second.

    when the first channel is exhaused, read from second.

    Definition Classes
    Input
  12. def aread: Future[B]

    async version of read.

    async version of read. Immediatly return future, which will contains result of read or failur with StreamClosedException in case of stream is closed.

    Definition Classes
    Input
  13. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  14. def async: AnyRef { ... /* 3 definitions in type refinement */ }
    Definition Classes
    Input
  15. def atake(n: Int): Future[IndexedSeq[B]]

    return feature which contains sequence from first n elements.

    return feature which contains sequence from first n elements.

    Definition Classes
    Input
  16. def cbread[C](f: (ContRead[B, C]) => Option[(In[B]) => Future[Continuated[C]]], ft: FlowTermination[C]): Unit

    apply f, when input will be ready and send result to API processor

    apply f, when input will be ready and send result to API processor

    Definition Classes
    FutureMappedInput
  17. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  18. lazy val closeless: Input[B]

    returns

    Input without close event: i.e. reading from closeless channel after channel close will wait forever instead throwing CloseChannelException

    Definition Classes
    Input
  19. def dup(): (Input[B], Input[B])

    duplicate input

    duplicate input

    Definition Classes
    Input
  20. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  22. def filter(p: (B) => Boolean): Input[B]
    Definition Classes
    Input
  23. def flatFold(fun: (Input[B], B) => Input[B]): Input[B]
    Definition Classes
    Input
  24. def flatMap[B](g: (B) => Input[B]): Input[B]
    Definition Classes
    Input
  25. def flatMapOp[B](g: (B) => Input[B])(op: (Input[B], Input[B]) => Input[B]): Input[B]
    Definition Classes
    Input
  26. macro def fold[S, B](s0: S)(f: (S, B) => S): S

    fold opeations, available inside async bloc.

    fold opeations, available inside async bloc. go { val sum = ch.fold(0){ (s,n) => s+n } }

    Definition Classes
    Input
  27. macro def foreach(f: (B) => Unit): Unit

    run f each time when new object is arrived.

    run f each time when new object is arrived. Ended when input closes.

    must be inside go/async/action block.

    Definition Classes
    Input
  28. def foreachAsync(f: (B) => Future[Unit])(implicit ec: ExecutionContext): Future[Unit]
    Definition Classes
    Input
  29. def foreachSync(f: (B) => Unit): Future[Unit]
    Definition Classes
    Input
  30. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  31. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  32. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  33. def map[B](g: (B) => B): Input[B]
    Definition Classes
    Input
  34. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  35. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  36. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  37. def or(other: Input[B]): Input[B]

    synonim for non-deteremenistics choice.

    synonim for non-deteremenistics choice.

    Definition Classes
    Input
  38. def prepend(a: B): Input[B]
    Definition Classes
    Input
  39. macro def read: B

    read object from channel.

    read object from channel. Must be situated inside async/go/action block.

    Definition Classes
    Input
  40. def seq: AnyRef { def flatMap[B](g: B => gopher.channels.Input[B]): gopher.channels.Input[B] }
    Definition Classes
    Input
  41. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  42. def timedAread(waitTime: FiniteDuration): Future[B]
    Definition Classes
    Input
  43. def toString(): String
    Definition Classes
    AnyRef → Any
  44. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  45. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  46. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  47. def withFilter(p: (B) => Boolean): Input[B]
    Definition Classes
    Input
  48. def withInputTimeouts(timeout: FiniteDuration): (Input[B], Input[FiniteDuration])

    return pair of inputs (ready, timeouts), such that when you read from ready you receive element from this and if during reading you wait more than specified timeout, than timeout message is appear in timeouts

    return pair of inputs (ready, timeouts), such that when you read from ready you receive element from this and if during reading you wait more than specified timeout, than timeout message is appear in timeouts

    val (inReady, inTimeouts) = in withInputTimeouts (10 seconds) select.forever { case x: inReady.read => Console.println(s"received value ${value}") case x: inTimeouts.read => Console.println(s"timeout occured") }

    Definition Classes
    Input
  49. def zip[B](x: Input[B]): Input[(B, B)]
    Definition Classes
    Input
  50. def zip[B](x: Iterable[B]): Input[(B, B)]
    Definition Classes
    Input
  51. def |(other: Input[B]): Input[B]

    return input merged with 'other'.

    return input merged with 'other'. (i.e. non-determenistics choice)

    Definition Classes
    Input

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from Input[B]

Inherited from GopherAPIProvider

Inherited from AnyRef

Inherited from Any

Ungrouped