Package org.glassfish.pfl.tf.timer.spi
Class TimerEvent
- java.lang.Object
-
- org.glassfish.pfl.tf.timer.spi.TimerEvent
-
public class TimerEvent extends java.lang.Object
Represents a particular observable event. We are mostly interested in measuring how long an operation takes. An operation is typically represented by a Timer, and then the timer is used to generate a TimerEvent at the entry to and exit from the operation.Note that this class can also be used as a base class, in case there is a need to attach extra information to a TimerEvent.
All access to this class is unsynchronized. This class must be used either as an immutable (no calls to update), or access must be restricted to a single thread (as in an iterator).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TimerEvent.TimerEventType
-
Field Summary
Fields Modifier and Type Field Description private TimerEvent.TimerEventType
etype
private long
time
private Timer
timer
-
Constructor Summary
Constructors Constructor Description TimerEvent(TimerEvent te)
TimerEvent(Timer timer, TimerEvent.TimerEventType etype)
Create a TimerEvent at the current time.TimerEvent(Timer timer, TimerEvent.TimerEventType etype, long time)
Create a TimerEvent at the given time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
incrementTime(long update)
private void
internalSetData(Timer timer, TimerEvent.TimerEventType etype, long time)
long
time()
Time of event in nanoseconds since the TimerLog was created or cleared.Timer
timer()
The name of the Timer used to create this entry.java.lang.String
toString()
TimerEvent.TimerEventType
type()
Type of event: ENTER for start of interval for a Timer, EXIT for end of the interval.void
update(Timer timer, TimerEvent.TimerEventType etype, long time)
Re-use the same TimerEvent instance with different data.
-
-
-
Field Detail
-
timer
private Timer timer
-
etype
private TimerEvent.TimerEventType etype
-
time
private long time
-
-
Constructor Detail
-
TimerEvent
public TimerEvent(TimerEvent te)
-
TimerEvent
public TimerEvent(Timer timer, TimerEvent.TimerEventType etype)
Create a TimerEvent at the current time.
-
TimerEvent
public TimerEvent(Timer timer, TimerEvent.TimerEventType etype, long time)
Create a TimerEvent at the given time.
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
update
public void update(Timer timer, TimerEvent.TimerEventType etype, long time)
Re-use the same TimerEvent instance with different data. Used to create flyweight instances for iteration over a collection of TimerEvent instances.
-
internalSetData
private void internalSetData(Timer timer, TimerEvent.TimerEventType etype, long time)
-
incrementTime
public void incrementTime(long update)
-
timer
public Timer timer()
The name of the Timer used to create this entry.
-
type
public TimerEvent.TimerEventType type()
Type of event: ENTER for start of interval for a Timer, EXIT for end of the interval.
-
time
public long time()
Time of event in nanoseconds since the TimerLog was created or cleared.
-
-