class QueuedSocketWriter
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
private boolean |
done |
private boolean |
flushed
Set to true when flushing is completed.
|
private java.lang.Object |
flushMutex
Sending thread that requests the flushing, waits on this mutex until
notified that the flush was completed (boolean 'flushed' below set to true).
|
private int |
instanceId |
private static int |
instanceIdCounter |
(package private) static java.util.logging.Logger |
LOGGER |
private static java.lang.String |
MSG_EXIT_LOOP |
private static java.lang.String |
MSG_FLUSH_MSGS |
(package private) java.io.PrintWriter |
out
The actual writer object which will send printed data over the socket.
|
private java.util.concurrent.LinkedBlockingQueue<java.lang.String> |
queue
The actual queue holding all messages that need to be sent.
|
Constructor and Description |
---|
QueuedSocketWriter(java.net.Socket socket) |
Modifier and Type | Method and Description |
---|---|
void |
flushMessages()
Enqueues a flush marker and waits on the mutex until the flushing of all
messages enqueued prior to the marker have been sent.
|
private java.lang.String |
readNextFromQueue()
We use no timeout while waiting for next message in the queue.
|
void |
run() |
void |
sendMessage(java.lang.String message) |
void |
stopWriter() |
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, toString, yield
static final java.util.logging.Logger LOGGER
private static final java.lang.String MSG_EXIT_LOOP
private static final java.lang.String MSG_FLUSH_MSGS
private final java.util.concurrent.LinkedBlockingQueue<java.lang.String> queue
java.io.PrintWriter out
private final java.lang.Object flushMutex
private boolean flushed
private boolean done
private static int instanceIdCounter
private final int instanceId
public QueuedSocketWriter(java.net.Socket socket) throws java.io.IOException
java.io.IOException
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void flushMessages()
public void stopWriter()
public void sendMessage(java.lang.String message)
private java.lang.String readNextFromQueue()