net.gleamynode.netty2
Class OrderedEventDispatcher
java.lang.Object
net.gleamynode.netty2.AbstractThreadPooledEventDispatcher
net.gleamynode.netty2.OrderedEventDispatcher
- All Implemented Interfaces:
- EventDispatcher, EventDispatcherMBean, OrderedEventDispatcherMBean, ThreadPooledEventDispatcher, ThreadPooledEventDispatcherMBean
- public class OrderedEventDispatcher
- extends AbstractThreadPooledEventDispatcher
- implements ThreadPooledEventDispatcher, OrderedEventDispatcherMBean
A thread-pooled EventDispatcher
that the events for the same session
occurs in the same order it was generated actually. It has synchronization
overhead compared to SimpleEventDispatcher
, but it will be more
useful in most situations. See SimpleEventDispatcher
for its
shortness.
Please note that OrderedEventDispatcher
does not guarantee read and
write events are fired in order, but it does guarantee that the same type of
events will be fired in order:
Case 1: 'messageReceived' for the response message is fired before
'messageSent' for the request message is.)
Case 2: 'messageSent' or 'exceptionCaught' event is fired after
'connectionClosed' is fired.
I can't find any easy way to order read and write events for now.
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/)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OrderedEventDispatcher
public OrderedEventDispatcher()
- Creates a new instance.
getWaitingEventSize
public int getWaitingEventSize()
- Description copied from interface:
EventDispatcher
- Returns the number of session events that are still not dispatched to
SessionListener
s.
- 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.