class PrintLogger extends Logger
The pulse logger is designed in such a way as to gather all of the pulse statistics
together even though half of the pulse occurs on the FX thread and half on the
render thread, and therefore two sets of pulse data are being accumulated
concurrently. The pulseStart
, pulseEnd
, renderStart
,
and renderEnd
methods must be called appropriately by the runtime
to ensure that the logging system works correctly.
Modifier and Type | Class and Description |
---|---|
private static class |
PrintLogger.Counter
A mutable integer to be used in the counter map
|
private class |
PrintLogger.PulseData
The data we collect per pulse.
|
(package private) class |
PrintLogger.ThreadLocalData |
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicInteger |
active
A synchronization object for printing arbitrage.
|
private static int |
AVAILABLE
PulseData object states
|
private static int |
COMPLETE |
private static int |
EXIT_ON_PULSE
Optionally exit after a given number of pulses
|
private PrintLogger.PulseData |
fxData
References to PulseData for the FX thread (fxData) and the Render thread (renderData).
|
private java.lang.Thread |
fxThread |
private PrintLogger.PulseData |
head
The queue of all PulseData objects, both available and those in use.
|
private static int |
INCOMPLETE |
private static int |
INTER_PULSE_DATA |
private long |
lastPulseStartTime
Keeps track of the start of the previous pulse, such that we can print out
the time interval between the start of pulses.
|
private java.lang.ThreadLocal<PrintLogger.ThreadLocalData> |
phaseData |
private static PrintLogger |
printLogger
A reference to the pulse logger.
|
private int |
pulseCount
We have a simple counter that keeps track of the current pulse number.
|
private PrintLogger.PulseData |
renderData
References to PulseData for the FX thread (fxData) and the Render thread (renderData).
|
private PrintLogger.PulseData |
tail |
private static long |
THRESHOLD
A time in milliseconds which defines the threshold.
|
private int |
wrapCount
When printing the truncated form of the pulse, we just print one truncated
form after another, such as:
[5][2][4]
This way we don't cause the console to scroll far vertically in the case of fast
pulses.
|
Modifier | Constructor and Description |
---|---|
private |
PrintLogger()
Disallow instantiation.
|
Modifier and Type | Method and Description |
---|---|
void |
addMessage(java.lang.String message)
Adds a message to the log for the pulse.
|
private PrintLogger.PulseData |
allocate(int n)
Allocate and initialize a PulseData object
|
static Logger |
getInstance() |
void |
incrementCounter(java.lang.String counter)
Increments the given named per-pulse counter.
|
void |
newPhase(java.lang.String name) |
void |
pulseEnd()
Must be called at the end of the pulse.
|
void |
pulseStart()
MUST be called at the start of every pulse.
|
void |
renderEnd()
Must be called at the end of rendering, if a previous
call to
renderStart() had been made. |
void |
renderStart()
Must be called before any set of render jobs
for a given pulse begin.
|
private static PrintLogger printLogger
private static long THRESHOLD
private static final int EXIT_ON_PULSE
private int pulseCount
private static final int INTER_PULSE_DATA
private volatile int wrapCount
private volatile PrintLogger.PulseData fxData
private volatile PrintLogger.PulseData renderData
private long lastPulseStartTime
private java.lang.Thread fxThread
private final java.lang.ThreadLocal<PrintLogger.ThreadLocalData> phaseData
private PrintLogger.PulseData head
private PrintLogger.PulseData tail
private java.util.concurrent.atomic.AtomicInteger active
private static final int AVAILABLE
private static final int INCOMPLETE
private static final int COMPLETE
public static Logger getInstance()
private PrintLogger.PulseData allocate(int n)
public void pulseStart()
pulseStart
in class Logger
public void renderStart()
renderStart
in class Logger
public void pulseEnd()
public void renderEnd()
renderStart()
had been made. This will cause the pulse
data to be logged.public void addMessage(java.lang.String message)
addMessage
in class Logger
message
- The message to log. A newline will be added automatically.public void incrementCounter(java.lang.String counter)
incrementCounter
in class Logger
counter
- The name for the counter.