Packages

  • package root
  • package akka
  • 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()
        }
      }
    }
    See also

    gopher.GopherAPI

    gopher.channels.Channel

    gopher.channels.Input

    gopher.channels.Output

    gopher.channels.SelectorBuilder

    gopher.channels.SelectFactory

p

root package

package root

Package Members

  1. package akka
  2. 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()
        }
      }
    }
    See also

    gopher.GopherAPI

    gopher.channels.Channel

    gopher.channels.Input

    gopher.channels.Output

    gopher.channels.SelectorBuilder

    gopher.channels.SelectFactory

Ungrouped