Package me.neznamy.tab.shared
Class CpuManager
java.lang.Object
me.neznamy.tab.shared.CpuManager
- All Implemented Interfaces:
me.neznamy.tab.api.task.ThreadManager
A class which measures CPU usage of all tasks inserted into it and shows usage
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs new instance and starts repeating task that resets values in configured interval -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMethodTime(String method, long nanoseconds) Adds method time to specified methodvoidaddPlaceholderTime(String placeholder, long nanoseconds) Adds placeholder time to specified placeholdervoidAdds cpu time to specified feature and usage typevoidAdds cpu time to specified feature and usage typevoidCancels all tasks, new instance is set to avoid errors when starting tasks on shutdown (such as packet readers)voidenable()Marks cpu manager as loaded and submits all queued tasksReturns map of CPU usage per feature and type in the previous time periodReturns cpu usage map of methods previous time periodReturns cpu usage map of placeholders from previous time periodReturns map of sent packets per feature in previous time periodvoidpacketSent(String feature) Increments packets sent by 1 of specified featurerunMeasuredTask(String feature, String type, Runnable task) runMeasuredTask(me.neznamy.tab.api.TabFeature feature, String type, Runnable task) Future<?>runTaskLater(int delayMilliseconds, me.neznamy.tab.api.TabFeature feature, String type, Runnable task) me.neznamy.tab.api.task.RepeatingTaskstartRepeatingMeasuredTask(int intervalMilliseconds, me.neznamy.tab.api.TabFeature feature, String type, Runnable task) me.neznamy.tab.api.task.RepeatingTaskstartRepeatingTask(int intervalMilliseconds, Runnable task)
-
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
Returns cpu usage map of placeholders from previous time period- Returns:
- cpu usage map of placeholders
-
getMethodUsage
Returns cpu usage map of methods previous time period- Returns:
- cpu usage map of methods
-
getSentPackets
Returns map of sent packets per feature in previous time period- Returns:
- map of sent packets per feature
-
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
Adds cpu time to specified feature and usage type- Parameters:
feature- feature to add time totype- sub-feature to add time tonanoseconds- time to add
-
addTime
Adds cpu time to specified feature and usage type- Parameters:
feature- feature to add time totype- sub-feature to add time tonanoseconds- time to add
-
addPlaceholderTime
Adds placeholder time to specified placeholder- Parameters:
placeholder- placeholder to add time tonanoseconds- time to add
-
addMethodTime
Adds method time to specified method- Parameters:
method- method to add time tonanoseconds- time to add
-
packetSent
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:
runMeasuredTaskin interfaceme.neznamy.tab.api.task.ThreadManager
-
runMeasuredTask
- Specified by:
runMeasuredTaskin interfaceme.neznamy.tab.api.task.ThreadManager
-
runTask
- Specified by:
runTaskin interfaceme.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:
startRepeatingMeasuredTaskin interfaceme.neznamy.tab.api.task.ThreadManager
-
startRepeatingTask
public me.neznamy.tab.api.task.RepeatingTask startRepeatingTask(int intervalMilliseconds, Runnable task) - Specified by:
startRepeatingTaskin interfaceme.neznamy.tab.api.task.ThreadManager
-
runTaskLater
public Future<?> runTaskLater(int delayMilliseconds, me.neznamy.tab.api.TabFeature feature, String type, Runnable task) - Specified by:
runTaskLaterin interfaceme.neznamy.tab.api.task.ThreadManager
-
getThreadPool
-