public class TPC
extends java.lang.Object
TPC = Thread Performance Context
The intent of thread performance context is to annotate a thread with information that describes some information about what that thread is doing and what system it's task belongs to.
Dedicated threads may be permanently annotated, whereas tasks running on shared threads may annonate their thread temporarily and remove the annotation when the task is finished.
Modifier and Type | Class and Description |
---|---|
static class |
TPC.Systems
This "class" simply contains some constant strings for common systems to encourage consistency.
|
static class |
TPC.ThreadEntry
Describes the context in which a thread is executing
|
static interface |
TPC.TPCUnset
Callback object returned by the various "set*" methods that is used to un-set whatever was previously set.
|
Constructor and Description |
---|
TPC() |
Modifier and Type | Method and Description |
---|---|
static TPC.ThreadEntry |
get(java.lang.Thread thread) |
static void |
initTimer(java.util.Timer timer,
java.lang.String system)
If you know that a java.util.Timer will always be used for a specific system, you can set it up here, rather
than try to set/unset in your timer tasks.
|
static java.util.concurrent.ThreadFactory |
newThreadFactory(java.lang.String name,
java.lang.String system)
Creates a new thread factory that will set the name and TPC system on each thread created.
|
static TPC.TPCUnset |
setScope(int scope)
Sets the "scope" of the current thread to either Gateway, Designer, or Client.
|
static TPC.TPCUnset |
setSystem(java.lang.String system)
Sets the system for the current (calling) thread.
|
static TPC.TPCUnset |
setSystem(java.lang.Thread thread,
java.lang.String system)
Sets the system for a thread other than the current (calling) thread.
|
public static TPC.TPCUnset setScope(int scope)
scope
- an ApplicationScope code.ApplicationScope
public static TPC.TPCUnset setSystem(java.lang.String system)
Sets the system for the current (calling) thread. A "system" is an arbitrary string describing roughly
what part of the system owns the task running on this thread. See constants in System
for some
examples.
If your thread is dedicated to a system, you may safely ignore and never use the TPCUnset returned from this call.
public static TPC.TPCUnset setSystem(java.lang.Thread thread, java.lang.String system)
public static void initTimer(java.util.Timer timer, java.lang.String system)
If you know that a java.util.Timer will always be used for a specific system, you can set it up here, rather than try to set/unset in your timer tasks.
The implementation will schedule a task immediately on the timer, which will set the system on it's calling thread (which will be the timer's private TimerThread)
public static TPC.ThreadEntry get(java.lang.Thread thread)
public static java.util.concurrent.ThreadFactory newThreadFactory(java.lang.String name, java.lang.String system)
NamedThreadFactory