The Artima Developer Community
Sponsored Link

Akka Concurrency Forum
Ch 6: page 133

2 replies on 1 page. Most recent reply: Dec 6, 2012 7:59 AM by Mirco Dotta

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 2 replies on 1 page
Mirco Dotta

Posts: 4
Nickname: mirco
Registered: Jul, 2011

Ch 6: page 133 Posted: Dec 2, 2012 10:07 AM
Reply to this message Reply
Advertisement
Hi Derek,

I'm looking at the below testing code and I believe it is incorrect.
"send the event to our test actor" in {
val testA = TestActorRef[TestEventSource]
testA ! RegisterListener(testActor)
testA.underlyingActor.sendEvent("Fibonacci")
expectMsg("Fibonacci")
}

Specifically, `testA.underlyingActor.sendEvent("Fibonacci")` could be executed before the testA actor has a chance to process the RegisterListener message, because the two are ran on different threads.


Derek Wyatt

Posts: 69
Nickname: dwyatt
Registered: Oct, 2012

Re: Ch 6: page 133 Posted: Dec 3, 2012 2:14 AM
Reply to this message Reply
There's a little trick involved in the TestActorRef - and the book doesn't make this clear at all - it overrides the dispatcher to use the CallingThreadDispatcher. So, there's no race condition here.

I'll have to see if I can make this more clear.

Mirco Dotta

Posts: 4
Nickname: mirco
Registered: Jul, 2011

Re: Ch 6: page 133 Posted: Dec 6, 2012 7:59 AM
Reply to this message Reply
Ooooh, I see, really elegant. Nice trick!

Thanks a lot.

Flat View: This topic has 2 replies on 1 page
Topic: Slightly off topic Previous Topic   Next Topic Topic: Code Coverage

Sponsored Links



Google
  Web Artima.com   

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