akka.dispatch
Class BalancingDispatcher

java.lang.Object
  extended by akka.dispatch.MessageDispatcher
      extended by akka.dispatch.Dispatcher
          extended by akka.dispatch.BalancingDispatcher
All Implemented Interfaces:
BatchingExecutor, java.util.concurrent.Executor, scala.concurrent.ExecutionContext, scala.concurrent.ExecutionContextExecutor

public class BalancingDispatcher
extends Dispatcher

An executor based event driven dispatcher which will try to redistribute work from busy actors to idle actors. It is assumed that all actors using the same instance of this dispatcher can process all messages that have been sent to one of the actors. I.e. the actors belong to a pool of actors, and to the client there is no guarantee about which actor instance actually processes a given message.

Although the technique used in this implementation is commonly known as "work stealing", the actual implementation is probably best described as "work donating" because the actor of which work is being stolen takes the initiative.

The preferred way of creating dispatchers is to define configuration of it and use the the lookup method in Dispatchers.

See Also:
BalancingDispatcher, Dispatchers

Nested Class Summary
 
Nested classes/interfaces inherited from interface scala.concurrent.ExecutionContext
scala.concurrent.ExecutionContext.Implicits$
 
Constructor Summary
BalancingDispatcher(MessageDispatcherConfigurator _configurator, java.lang.String _id, int throughput, scala.concurrent.duration.Duration throughputDeadlineTime, MailboxType _mailboxType, ExecutorServiceFactoryProvider _executorServiceFactoryProvider, scala.concurrent.duration.FiniteDuration _shutdownTimeout, boolean attemptTeamWork)
           
 
Method Summary
protected  Mailbox createMailbox(Cell actor, MailboxType mailboxType)
          INTERNAL API
protected  void dispatch(ActorCell receiver, Envelope invocation)
          INTERNAL API
 MessageQueue messageQueue()
          INTERNAL API
protected  void register(ActorCell actor)
          If you override it, you must call it.
 java.util.concurrent.ConcurrentSkipListSet<ActorCell> team()
          INTERNAL API
protected  void teamWork()
           
protected  void unregister(ActorCell actor)
          If you override it, you must call it.
 
Methods inherited from class akka.dispatch.Dispatcher
executeTask, executorService, id, registerForExecution, shutdown, shutdownTimeout, systemDispatch, throughput, throughputDeadlineTime, toString
 
Methods inherited from class akka.dispatch.MessageDispatcher
actors, attach, configurator, debug, detach, eventStream, inhabitants, isThroughputDeadlineTimeDefined, mailboxes, printActors, reportFailure, RESCHEDULED, resubmitOnBlock, resume, SCHEDULED, suspend, unbatchedExecute, UNSCHEDULED
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface akka.dispatch.BatchingExecutor
batchable, execute
 
Methods inherited from interface scala.concurrent.ExecutionContext
execute, prepare
 

Constructor Detail

BalancingDispatcher

public BalancingDispatcher(MessageDispatcherConfigurator _configurator,
                           java.lang.String _id,
                           int throughput,
                           scala.concurrent.duration.Duration throughputDeadlineTime,
                           MailboxType _mailboxType,
                           ExecutorServiceFactoryProvider _executorServiceFactoryProvider,
                           scala.concurrent.duration.FiniteDuration _shutdownTimeout,
                           boolean attemptTeamWork)
Method Detail

team

public java.util.concurrent.ConcurrentSkipListSet<ActorCell> team()
INTERNAL API

Returns:
(undocumented)

messageQueue

public MessageQueue messageQueue()
INTERNAL API

Returns:
(undocumented)

createMailbox

protected Mailbox createMailbox(Cell actor,
                                MailboxType mailboxType)
Description copied from class: Dispatcher
INTERNAL API

Overrides:
createMailbox in class Dispatcher
Parameters:
actor - (undocumented)
mailboxType - (undocumented)
Returns:
(undocumented)

register

protected void register(ActorCell actor)
Description copied from class: MessageDispatcher
If you override it, you must call it. But only ever once. See "attach" for only invocation.

INTERNAL API

Overrides:
register in class MessageDispatcher
Parameters:
actor - (undocumented)

unregister

protected void unregister(ActorCell actor)
Description copied from class: MessageDispatcher
If you override it, you must call it. But only ever once. See "detach" for the only invocation

INTERNAL API

Overrides:
unregister in class MessageDispatcher
Parameters:
actor - (undocumented)

dispatch

protected void dispatch(ActorCell receiver,
                        Envelope invocation)
Description copied from class: Dispatcher
INTERNAL API

Overrides:
dispatch in class Dispatcher
Parameters:
receiver - (undocumented)
invocation - (undocumented)

teamWork

protected void teamWork()