java.lang.Object
com.inductiveautomation.ignition.common.execution.TPC

public class TPC extends 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 its task belongs to.

Dedicated threads may be permanently annotated, whereas tasks running on shared threads may annotate their thread temporarily and remove the annotation when the task is finished.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    This class simply contains some constant strings for common systems to encourage consistency.
    static class 
    Describes the context in which a thread is executing
    static interface 
    Callback object returned by the various "set*" methods that is used to un-set whatever was previously set.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TPC()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    get(Thread thread)
     
    static void
    initTimer(Timer timer, 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.
    Creates a new thread factory that will set the name and TPC system on each thread created.
    setScope(int scope)
    Sets the "scope" of the current thread to either Gateway, Designer, or Client.
    setSystem(String system)
    Sets the system for the current (calling) thread.
    setSystem(Thread thread, String system)
    Sets the system for a thread other than the current (calling) thread.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TPC

      public TPC()
  • Method Details

    • setScope

      public static TPC.TPCUnset setScope(int scope)
      Sets the "scope" of the current thread to either Gateway, Designer, or Client. This will correctly default to whatever scope the current JVM is defined by. However, in the Gateway it will be overridden by tasks coming in from the client/designer so that thread load can be understood in context of the originating scope.
      Parameters:
      scope - an ApplicationScope code.
      Returns:
      a TPCUnset used to clear the scope that was set. It will return to whatever scope was set before setScope was called.
      See Also:
    • setSystem

      public static TPC.TPCUnset setSystem(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.

      Returns:
      a TPCUnset object that can be used to return the system to whatever it was previous to this call
    • setSystem

      public static TPC.TPCUnset setSystem(Thread thread, String system)
      Sets the system for a thread other than the current (calling) thread.
    • initTimer

      public static void initTimer(Timer timer, 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)

    • get

      public static TPC.ThreadEntry get(Thread thread)
    • newThreadFactory

      public static ThreadFactory newThreadFactory(String name, String system)
      Creates a new thread factory that will set the name and TPC system on each thread created. It is encouraged that this be used instead of NamedThreadFactory
      Parameters:
      name - Thread name used for threads created by this factory
      system - TPC system name that will be attached to all threads created by this factory.
      Returns:
      A ThreadFactory that will automatically name and annotate threads with TPC system information.