public class TaggedSocketChannel extends java.lang.Thread
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.Integer,java.util.concurrent.BlockingQueue> |
queues
Queues for each message tag.
|
protected SocketChannel |
sc
Underlying socket channel.
|
| Constructor and Description |
|---|
TaggedSocketChannel(SocketChannel s)
Constructs a tagged socket channel on the given socket channel s.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the channel.
|
SocketChannel |
getSocket()
Get the SocketChannel
|
void |
init()
thread initialization and start.
|
int |
messages()
Number of messages.
|
java.lang.Object |
receive(java.lang.Integer tag)
Receive an object.
|
void |
run()
Run receive() in an infinite loop.
|
void |
send(java.lang.Integer tag,
java.lang.Object v)
Sends an object.
|
int |
tagSize()
Number of tags.
|
void |
terminate()
Terminate the TaggedSocketChannel.
|
java.lang.String |
toString()
To string.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yieldprotected final SocketChannel sc
protected final java.util.Map<java.lang.Integer,java.util.concurrent.BlockingQueue> queues
public TaggedSocketChannel(SocketChannel s)
s - A socket channel object.public void init()
public SocketChannel getSocket()
public void send(java.lang.Integer tag, java.lang.Object v) throws java.io.IOException
tag - message tagv - object to sendjava.io.IOExceptionpublic java.lang.Object receive(java.lang.Integer tag) throws java.lang.InterruptedException, java.io.IOException, java.lang.ClassNotFoundException
tag - message tagjava.lang.InterruptedExceptionjava.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic void close()
public java.lang.String toString()
toString in class java.lang.ThreadThread.toString()public int tagSize()
public int messages()
public void run()
run in interface java.lang.Runnablerun in class java.lang.ThreadThread.run()public void terminate()