The Artima Developer Community
Sponsored Link

Akka Concurrency Forum
Chapter 8 Page 198 actorOf in startControls()

3 replies on 1 page. Most recent reply: Nov 28, 2012 2:01 AM by Derek Wyatt

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Lawrence MacFadyen

Posts: 7
Nickname: 84427
Registered: Oct, 2012

Chapter 8 Page 198 actorOf in startControls() Posted: Nov 27, 2012 1:11 PM
Reply to this message Reply
Advertisement
In the code for Building the Basic Hierarchy section, shouldn't there be a context.actorOf instead of just actorOf? Same thing occurs a couple more times on page 198 and 199 in startPeople(). Am I missing something?


def startControls() {
val controls = actorOf(Props(new IsolatedResumeSupervisor with OneForOneStrategyFactory {
def childStarter() {
val alt = context.actorOf(Props(newAltimeter), "Altimeter")
context.actorOf(Props(newAutopilot), "AutoPilot")
context.actorOf(Props(new ControlSurfaces(alt)), "ControlSurfaces")
}
}), "Controls")
Await.result(controls ? WaitForStart, 1.second)
}


Derek Wyatt

Posts: 69
Nickname: dwyatt
Registered: Oct, 2012

Re: Chapter 8 Page 198 actorOf in startControls() Posted: Nov 27, 2012 5:01 PM
Reply to this message Reply
I think it's me who missed something here. The code is entirely valid, provided that you do an import context._ at the top of the Plane, like this:

class Plane extends Actor with ActorLogging {
import context._

// more stuff here

def startControls() {
// perfectly fine due to the import
val controls = actorOf(...)
}
}


It's in the code that I have, but the book doesn't seem to include that bit of code. I'll add that to the list of things to fix.

Thanks!
Derek

Lawrence MacFadyen

Posts: 7
Nickname: 84427
Registered: Oct, 2012

Re: Chapter 8 Page 198 actorOf in startControls() Posted: Nov 27, 2012 5:45 PM
Reply to this message Reply
Thanks for quick response - that makes sense.

One other issue in that same code fragment - and maybe it is another import issue. The one line with:

Await.result(controls ? WaitForStart, 1.second)

does not compile, with these errors:

not enough arguments for method seconds: (implicit ev: scala.concurrent.duration.DurationConversions.Classifier[Any])ev.R. Unspecified value parameter ev. Plane.scala

could not find implicit value for parameter ev: scala.concurrent.duration.DurationConversions.Classifier[Any] Plane.scala

If I split it up a bit and provide implicit timeout it compiles fine as follows:

implicit val timeout: Timeout = 1 seconds
val future = controls ? WaitForStart
Await.result(future, 1.second)

This time am I missing something :)?

Thanks

Derek Wyatt

Posts: 69
Nickname: dwyatt
Registered: Oct, 2012

Re: Chapter 8 Page 198 actorOf in startControls() Posted: Nov 28, 2012 2:01 AM
Reply to this message Reply
I don't think you're missing anything here either. The ask pattern is going to need that implicit timeout, which should be defined as an implicit in the Plane (again, it's in the code, but not code that is included in the book).

But, not all of the change you've made is necessary; the following would work:

class Plane ... {
implicit val askTimeout: Timeout = 1.second

// more stuff here

Await.result(controls ? WaitForStart, 1.second)

// etc...
}

Flat View: This topic has 3 replies on 1 page
Topic: Bad symbolic reference to class Duration in package util Previous Topic   Next Topic Topic: The fact that ...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use