net.gleamynode.netty2
Class AbstractThreadPooledEventDispatcher

java.lang.Object
  extended by net.gleamynode.netty2.AbstractThreadPooledEventDispatcher
All Implemented Interfaces:
EventDispatcher, ThreadPooledEventDispatcher
Direct Known Subclasses:
OrderedEventDispatcher, SimpleEventDispatcher

public abstract class AbstractThreadPooledEventDispatcher
extends Object
implements ThreadPooledEventDispatcher

A base class for thread-pooled event dispatchers.

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

Nested Class Summary
protected  class AbstractThreadPooledEventDispatcher.AbstractWorker
           
 
Field Summary
protected  List workers
           
 
Constructor Summary
protected AbstractThreadPooledEventDispatcher()
           
 
Method Summary
 void flush()
          (Optional operation) Flushes the buffered events.
 String getThreadNamePrefix()
          Returns the prefix of dispatcher thread name.
 int getThreadPoolSize()
          Returns the number of dispatcher threads.
 int getThreadPriority()
          Returns the priority of dispatcher threads.
 boolean isStarted()
          Returns true if this event dispatcher is started.
protected abstract  AbstractThreadPooledEventDispatcher.AbstractWorker newWorker()
           
protected abstract  AbstractThreadPooledEventDispatcher.AbstractWorker removeWorker()
           
 void setThreadNamePrefix(String threadNamePrefix)
          Sets the prefix of dispatcher thread name.
 void setThreadPoolSize(int newSize)
          Sets the number of dispatcher threads.
 void setThreadPriority(int newPriority)
          Sets the priority of dispatcher threads.
 void start()
          Starts this event dispatcher.
 void stop()
          Stops this event dispatcher.
 
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.EventDispatcher
fire, getWaitingEventSize
 

Field Detail

workers

protected final List workers
Constructor Detail

AbstractThreadPooledEventDispatcher

protected AbstractThreadPooledEventDispatcher()
Method Detail

start

public void start()
Description copied from interface: ThreadPooledEventDispatcher
Starts this event dispatcher. this method will silently return if it is already started.

Specified by:
start in interface ThreadPooledEventDispatcher

stop

public void stop()
Description copied from interface: ThreadPooledEventDispatcher
Stops this event dispatcher. This method will silently return if it is already stopped.

Specified by:
stop in interface ThreadPooledEventDispatcher

isStarted

public boolean isStarted()
Description copied from interface: ThreadPooledEventDispatcher
Returns true if this event dispatcher is started.

Specified by:
isStarted in interface ThreadPooledEventDispatcher

getThreadPoolSize

public int getThreadPoolSize()
Description copied from interface: ThreadPooledEventDispatcher
Returns the number of dispatcher threads.

Specified by:
getThreadPoolSize in interface ThreadPooledEventDispatcher

setThreadPoolSize

public void setThreadPoolSize(int newSize)
Description copied from interface: ThreadPooledEventDispatcher
Sets the number of dispatcher threads. This property is adjustable in runtime.

Specified by:
setThreadPoolSize in interface ThreadPooledEventDispatcher

newWorker

protected abstract AbstractThreadPooledEventDispatcher.AbstractWorker newWorker()

removeWorker

protected abstract AbstractThreadPooledEventDispatcher.AbstractWorker removeWorker()

getThreadPriority

public int getThreadPriority()
Description copied from interface: ThreadPooledEventDispatcher
Returns the priority of dispatcher threads.

Specified by:
getThreadPriority in interface ThreadPooledEventDispatcher

setThreadPriority

public void setThreadPriority(int newPriority)
Description copied from interface: ThreadPooledEventDispatcher
Sets the priority of dispatcher threads.

Specified by:
setThreadPriority in interface ThreadPooledEventDispatcher

getThreadNamePrefix

public String getThreadNamePrefix()
Description copied from interface: ThreadPooledEventDispatcher
Returns the prefix of dispatcher thread name.

Specified by:
getThreadNamePrefix in interface ThreadPooledEventDispatcher

setThreadNamePrefix

public void setThreadNamePrefix(String threadNamePrefix)
Description copied from interface: ThreadPooledEventDispatcher
Sets the prefix of dispatcher thread name. This will help you to determine which thread is which when you debug. The actual thread name will be threadNamePrefix + '-' + threadId.

Specified by:
setThreadNamePrefix in interface ThreadPooledEventDispatcher

flush

public void flush()
Description copied from interface: EventDispatcher
(Optional operation) Flushes the buffered events. This method is invoked by ReadController#processEvent(Event)and WriteController#processEvent(Event)after the expected I/O operations have been completed. So you can implement EventDispatcherto buffer the fireXXX calls and fire (flush) them here in actually.

Specified by:
flush in interface EventDispatcher


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