public class DelayedWriter
extends java.lang.Thread
DELAY_S_PROP
.
Otherwise, default delay is defined by DELAY_S_DEFAULT
.Modifier and Type | Field and Description |
---|---|
protected boolean |
closing
set to true when the writer must be closed
|
protected static long |
delay_ms
minimum age of events before actually writing them
|
static java.lang.String |
DELAY_S_DEFAULT |
static java.lang.String |
DELAY_S_PROP |
protected java.util.SortedSet<BladeEvent> |
eventQ |
protected static long |
maxPending
maximum number of young events waiting to be written (subsumes delay_ms)
|
static java.lang.String |
MAXPENDING_DEFAULT |
static java.lang.String |
MAXPENDING_PROP |
protected long |
offset
Initial time in ms
|
protected java.io.BufferedWriter |
writer |
Constructor and Description |
---|
DelayedWriter(java.io.BufferedWriter out,
long dateOffset_ms)
Creates a delayed writer that will order blade events according to their
date, before actually writing them using the provided BufferedWriter object,
after the delay has expired.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying buffered writer, after flushing all pending
blade events to it.
|
void |
run()
The delay writer's activity consists in getting events from the
blade events queue when they are sufficiently old (with respect
to delay and blade event dates), and writing them to the
underlying buffered writer.
|
void |
write(BladeEvent event)
Delayed writing of a blade event.
|
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
protected static long delay_ms
public static final java.lang.String DELAY_S_PROP
public static final java.lang.String DELAY_S_DEFAULT
protected static long maxPending
public static final java.lang.String MAXPENDING_PROP
public static final java.lang.String MAXPENDING_DEFAULT
protected java.util.SortedSet<BladeEvent> eventQ
protected long offset
protected java.io.BufferedWriter writer
protected volatile boolean closing
public DelayedWriter(java.io.BufferedWriter out, long dateOffset_ms)
out
- the buffered writer to be used for finally writing blades eventdateOffset_ms
- the initial date in ms (this value will be subtracted
from the events dates when they are finally written to the buffered writer).public void write(BladeEvent event) throws java.io.IOException
event
- the blade event to writejava.io.IOException
- the delayed writer has been closed and
cannot be used anymore.public void close()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread