public interface BackgroundTaskExecutor
Allows for background processes to be run, or effectively async callbacks. This is done by passing this interface a
Qilletni strictly doesn't support multithreading, but native Java functions can for processing. Any async thread should NOT use any Qilletni APIs, aside from this class or any others that are deemed safe.
Runnable, which runs a condition ID. With that, the condition ID can be activated, meaning the next break in
expression invocation will run the runnable.
Qilletni strictly doesn't support multithreading, but native Java functions can for processing. Any async thread should NOT use any Qilletni APIs, aside from this class or any others that are deemed safe.
-
Method Summary
Modifier and TypeMethodDescriptionvoidBlocks the current thread and runs background tasks immediately when they become available.voidChecks if any conditions are triggered and runs them if they are.intrunWhenCondition(Runnable callback) A condition that is run in between expression invocation breaks when the condition ID is triggered.<T> intrunWhenCondition(Consumer<T> callback) A condition that is run in between expression invocation breaks when the condition ID is triggered.voidtriggerCondition(int conditionId) Activates a condition from its ID.voidtriggerCondition(int conditionId, Object param) Activates a condition from its ID.
-
Method Details
-
runWhenCondition
A condition that is run in between expression invocation breaks when the condition ID is triggered.- Parameters:
callback- The callback to invoke- Returns:
- A number representing a condition ID
-
runWhenCondition
A condition that is run in between expression invocation breaks when the condition ID is triggered.- Parameters:
callback- The callback to invoke with a given parameter. IftriggerCondition(int)is used for this condition instead oftriggerCondition(int, Object), the trigger is ignored.- Returns:
- A number representing a condition ID
-
triggerCondition
void triggerCondition(int conditionId) Activates a condition from its ID.- Parameters:
conditionId- The condition ID to activate
-
triggerCondition
Activates a condition from its ID.- Parameters:
conditionId- The condition ID to activateparam- The parameter given to the callback consumer
-
checkAndRunBackgroundTasks
void checkAndRunBackgroundTasks()Checks if any conditions are triggered and runs them if they are. This is mainly used for internal purposes, and should ONLY be run in the main thread. -
blockAndRunBackgroundTasks
void blockAndRunBackgroundTasks()Blocks the current thread and runs background tasks immediately when they become available.
-