Code Examples for

Actors in Scala

Return to chapter index

11 API Overview

  • 11.1 The actor traits Reactor, ReplyReactor, and Actor
  • 11.2 Control structures
  • 11.3 Futures
  • 11.4 Channels
  • 11.5 Remote Actors API
  • 11.1 The actor traits Reactor, ReplyReactor, and Actor

    11.2 Control structures


    actor { { react { case "hello" => // processing "hello" }: Unit } andThen { println("hi there") } }

    11.3 Futures

    11.4 Channels


    actor { var out: OutputChannel[String] = null val child = actor { react { case "go" => out ! "hello" } } val channel = new Channel[String] out = channel child ! "go" channel.receive { case msg => println(msg.length) } }
    case class ReplyTo(out: OutputChannel[String]) val child = actor { react { case ReplyTo(out) => out ! "hello" } } actor { val channel = new Channel[String] child ! ReplyTo(channel) channel.receive { case msg => println(msg.length) } }

    11.5 Remote Actors API

    For more information about Actors in Scala, please visit:

    http://www.artima.com/shop/actors_in_scala

    and:

    http://booksites.artima.com/actors_in_scala

    Copyright © 2011 Artima, Inc. All rights reserved.

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.