Package com.kosdev.kos.commons.util
Class TimedCallback
java.lang.Object
com.kosdev.kos.commons.util.TimedCallback
Wrapper for a callback that handles exceptions and measures the time the
callback took and logs a warning if it takes longer than expected. Since
most callbacks are intended to be completed quickly, this provides an easy
way to warn users when their code is unexpectedly using event threads for
long running tasks.
- Since:
- 10
- Version:
- 10
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCall the specified callback with the default warning time.static voidCall the specified callback with the default warning time.static intReturn the current default warning time.
-
Field Details
-
DEFAULT_WARNING_TIME_MS
public static final int DEFAULT_WARNING_TIME_MS- See Also:
-
-
Constructor Details
-
TimedCallback
public TimedCallback()
-
-
Method Details
-
getDefaultWarningTimeMs
public static int getDefaultWarningTimeMs()Return the current default warning time.- Since:
- 10
-
call
Call the specified callback with the default warning time.- Parameters:
name- name of the call for use in log messageslistener- the listener being called, the class name is used in log messagesr- the callback to run- Since:
- 10
-
call
Call the specified callback with the default warning time.- Parameters:
name- name of the call for use in log messageslistener- the listener being called, the class name is used in log messageswarningTimeMs- how long until a warning is generatedr- the callback to run- Since:
- 10
-