net.gleamynode.netty2
Class SimpleEventDispatcher

java.lang.Object
  extended bynet.gleamynode.netty2.AbstractThreadPooledEventDispatcher
      extended bynet.gleamynode.netty2.SimpleEventDispatcher
All Implemented Interfaces:
EventDispatcher, EventDispatcherMBean, SimpleEventDispatcherMBean, ThreadPooledEventDispatcher, ThreadPooledEventDispatcherMBean

public class SimpleEventDispatcher
extends AbstractThreadPooledEventDispatcher
implements ThreadPooledEventDispatcher, SimpleEventDispatcherMBean

A thread-pooled EventDispatcherthat the events for the same session does NOT occur in the same order it was generated actually. That is, the events might come in random order (e.g. messageReceived:SecondMessage, connectionEstablished,messageReceived:FirstMessage , connectionClosed,messageReceived:ThirdMessage). This dispatcher is appropriate for the case the order of event is not important. If so, use OrderedEventDispatcherinstead.

Set thread pool size (AbstractThreadPooledEventDispatcher.setThreadPoolSize(int)) and call AbstractThreadPooledEventDispatcher.start()to activate this event dispatcher.

Please note that dispatcher threads will not terminate even if AbstractThreadPooledEventDispatcher.stop()is invoked if there are any remaining events to process for this event dispatcher. They will be terminated when JVM exits because they are daemon threads.

Version:
$Rev: 4 $, $Date: 2005-04-18 12:04:09 +0900 $
Author:
Trustin Lee (http://gleamynode.net/dev/)

Nested Class Summary
 
Nested classes inherited from class net.gleamynode.netty2.AbstractThreadPooledEventDispatcher
AbstractThreadPooledEventDispatcher.AbstractWorker
 
Field Summary
 
Fields inherited from class net.gleamynode.netty2.AbstractThreadPooledEventDispatcher
workers
 
Constructor Summary
SimpleEventDispatcher()
          Creates a new instance.
 
Method Summary
 void fire(Event event)
          Fires the specified session event.
 int getWaitingEventSize()
          Returns the number of session events that are still not dispatched to SessionListeners.
protected  AbstractThreadPooledEventDispatcher.AbstractWorker newWorker()
           
protected  AbstractThreadPooledEventDispatcher.AbstractWorker removeWorker()
           
 
Methods inherited from class net.gleamynode.netty2.AbstractThreadPooledEventDispatcher
flush, getThreadNamePrefix, getThreadPoolSize, getThreadPriority, isStarted, setThreadNamePrefix, setThreadPoolSize, setThreadPriority, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.gleamynode.netty2.ThreadPooledEventDispatcher
getThreadNamePrefix, getThreadPoolSize, getThreadPriority, isStarted, setThreadNamePrefix, setThreadPoolSize, setThreadPriority, start, stop
 
Methods inherited from interface net.gleamynode.netty2.EventDispatcher
flush
 
Methods inherited from interface net.gleamynode.netty2.ThreadPooledEventDispatcherMBean
getThreadNamePrefix, getThreadPoolSize, getThreadPriority, isStarted, setThreadNamePrefix, setThreadPoolSize, setThreadPriority, start, stop
 

Constructor Detail

SimpleEventDispatcher

public SimpleEventDispatcher()
Creates a new instance.

Method Detail

getWaitingEventSize

public int getWaitingEventSize()
Description copied from interface: EventDispatcher
Returns the number of session events that are still not dispatched to SessionListeners.

Specified by:
getWaitingEventSize in interface EventDispatcher

newWorker

protected AbstractThreadPooledEventDispatcher.AbstractWorker newWorker()
Specified by:
newWorker in class AbstractThreadPooledEventDispatcher

removeWorker

protected AbstractThreadPooledEventDispatcher.AbstractWorker removeWorker()
Specified by:
removeWorker in class AbstractThreadPooledEventDispatcher

fire

public void fire(Event event)
Description copied from interface: EventDispatcher
Fires the specified session event.

Specified by:
fire in interface EventDispatcher


Copyright © 2004-2006 Trustin Lee. All Rights Reserved.