net.sf.jbaobab.io
Class ThreadedSocketCore<P>

java.lang.Object
  extended by net.sf.jbaobab.io.SimpleSocketCore<P>
      extended by net.sf.jbaobab.io.ThreadedSocketCore<P>
All Implemented Interfaces:
ChannelCore<P>, SocketCore<P>

public class ThreadedSocketCore<P>
extends SimpleSocketCore<P>

A SocketCore that runs Protocol jobs on root executor (obtained with ExecutorPool.getRootExecutor()) and runs on PacketHandler jobs given ExecutorService.

Author:
Oakyoon Cha
See Also:
ExecutorPool

Nested Class Summary
 class ThreadedSocketCore.PacketJobWorker
           
 class ThreadedSocketCore.ProtocolWorker
           
 
Field Summary
protected  ProtocolFactory<P> factory
           
protected  ExecutorService packetJobExecutor
           
protected  ThreadLocal<Protocol<P>> protocol
           
protected  ExecutorService protocolExecutor
           
 
Fields inherited from class net.sf.jbaobab.io.SimpleSocketCore
buffer, channel, DEBUG, EOF, queue, receiver, sender
 
Constructor Summary
ThreadedSocketCore(ProtocolFactory<P> factory)
           
ThreadedSocketCore(ProtocolFactory<P> factory, ExecutorService executor)
           
 
Method Summary
 ExecutorService executor()
           
 Protocol<P> protocol()
           
 int receive(PacketHandler<P> handler)
           
 
Methods inherited from class net.sf.jbaobab.io.SimpleSocketCore
channel, prepare, schedulePacket, scheduleShutdown, send, shutdown, toString, track
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

factory

protected ProtocolFactory<P> factory

protocol

protected ThreadLocal<Protocol<P>> protocol

protocolExecutor

protected ExecutorService protocolExecutor

packetJobExecutor

protected ExecutorService packetJobExecutor
Constructor Detail

ThreadedSocketCore

public ThreadedSocketCore(ProtocolFactory<P> factory,
                          ExecutorService executor)

ThreadedSocketCore

public ThreadedSocketCore(ProtocolFactory<P> factory)
Method Detail

executor

public ExecutorService executor()

protocol

public Protocol<P> protocol()
Specified by:
protocol in interface ChannelCore<P>
Overrides:
protocol in class SimpleSocketCore<P>

receive

public int receive(PacketHandler<P> handler)
            throws IOException
Specified by:
receive in interface ChannelCore<P>
Overrides:
receive in class SimpleSocketCore<P>
Throws:
IOException