tags:

views:

92

answers:

1

Behind the scenes, how is a mailbox (an actor's message queue) implemented in Scala Actors?

I thought it was MessageQueue, but it's been deprecated with the note that "this class is going to be removed in a future release". It looks like it might be in Channel, but I want the details of how the message queue itself is implemented.

+3  A: 

See: http://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_8_0_final/src/library/scala/concurrent/MailBox.scala
It looks like it's basically just a linked list, which is bypassed if there's a waiting receiver when a send is done. Senders and receivers synchronize on the MailBox object, with senders notifying to wake waiting receivers.

RD1