Class CpuManager

java.lang.Object
me.neznamy.tab.shared.CpuManager
All Implemented Interfaces:
me.neznamy.tab.api.task.ThreadManager

public class CpuManager extends Object implements me.neznamy.tab.api.task.ThreadManager
A class which measures CPU usage of all tasks inserted into it and shows usage
  • Constructor Details

    • CpuManager

      public CpuManager()
      Constructs new instance and starts repeating task that resets values in configured interval
  • Method Details

    • cancelAllTasks

      public void cancelAllTasks()
      Cancels all tasks, new instance is set to avoid errors when starting tasks on shutdown (such as packet readers)
    • enable

      public void enable()
      Marks cpu manager as loaded and submits all queued tasks
    • getPlaceholderUsage

      public Map<String,Float> getPlaceholderUsage()
      Returns cpu usage map of placeholders from previous time period
      Returns:
      cpu usage map of placeholders
    • getMethodUsage

      public Map<String,Float> getMethodUsage()
      Returns cpu usage map of methods previous time period
      Returns:
      cpu usage map of methods
    • getSentPackets

      public Map<String,AtomicInteger> getSentPackets()
      Returns map of sent packets per feature in previous time period
      Returns:
      map of sent packets per feature
    • getFeatureUsage

      public Map<String,Map<String,Float>> getFeatureUsage()
      Returns map of CPU usage per feature and type in the previous time period
      Returns:
      map of CPU usage per feature and type
    • addTime

      public void addTime(me.neznamy.tab.api.TabFeature feature, String type, long nanoseconds)
      Adds cpu time to specified feature and usage type
      Parameters:
      feature - feature to add time to
      type - sub-feature to add time to
      nanoseconds - time to add
    • addTime

      public void addTime(String feature, String type, long nanoseconds)
      Adds cpu time to specified feature and usage type
      Parameters:
      feature - feature to add time to
      type - sub-feature to add time to
      nanoseconds - time to add
    • addPlaceholderTime

      public void addPlaceholderTime(String placeholder, long nanoseconds)
      Adds placeholder time to specified placeholder
      Parameters:
      placeholder - placeholder to add time to
      nanoseconds - time to add
    • addMethodTime

      public void addMethodTime(String method, long nanoseconds)
      Adds method time to specified method
      Parameters:
      method - method to add time to
      nanoseconds - time to add
    • packetSent

      public void packetSent(String feature)
      Increments packets sent by 1 of specified feature
      Parameters:
      feature - feature to increment packet counter of
    • runMeasuredTask

      public Future<Void> runMeasuredTask(me.neznamy.tab.api.TabFeature feature, String type, Runnable task)
      Specified by:
      runMeasuredTask in interface me.neznamy.tab.api.task.ThreadManager
    • runMeasuredTask

      public Future<Void> runMeasuredTask(String feature, String type, Runnable task)
      Specified by:
      runMeasuredTask in interface me.neznamy.tab.api.task.ThreadManager
    • runTask

      public Future<Void> runTask(Runnable task)
      Specified by:
      runTask in interface me.neznamy.tab.api.task.ThreadManager
    • startRepeatingMeasuredTask

      public me.neznamy.tab.api.task.RepeatingTask startRepeatingMeasuredTask(int intervalMilliseconds, me.neznamy.tab.api.TabFeature feature, String type, Runnable task)
      Specified by:
      startRepeatingMeasuredTask in interface me.neznamy.tab.api.task.ThreadManager
    • startRepeatingTask

      public me.neznamy.tab.api.task.RepeatingTask startRepeatingTask(int intervalMilliseconds, Runnable task)
      Specified by:
      startRepeatingTask in interface me.neznamy.tab.api.task.ThreadManager
    • runTaskLater

      public Future<?> runTaskLater(int delayMilliseconds, me.neznamy.tab.api.TabFeature feature, String type, Runnable task)
      Specified by:
      runTaskLater in interface me.neznamy.tab.api.task.ThreadManager
    • getThreadPool

      public ThreadPoolExecutor getThreadPool()