Interface ISynchronizedWorkHandler
- All Known Implementing Classes:
NetworkRegistry.EventLoopSynchronizedWorkHandler
public interface ISynchronizedWorkHandler
Defines a replyHandler which can accept work that needs to be run synchronously, on the main thread of the game.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Executes a task on the main thread of the game.submitAsync
(Runnable task) Submits the given work to be run synchronously on the main thread of the game.<T> CompletableFuture<T>
submitAsync
(Supplier<T> task) Submits the given work to be run synchronously on the main thread of the game.
-
Method Details
-
execute
Executes a task on the main thread of the game.The runnable task is protected against exceptions, and any exceptions thrown will be logged.
- Parameters:
task
- The task to run.
-
submitAsync
Submits the given work to be run synchronously on the main thread of the game.This method will
not be guarded against exceptions.
If you need to guard against exceptions, callCompletableFuture.exceptionally(Function)
,CompletableFuture.exceptionallyAsync(Function)
}, or derivatives on the returned future.- Parameters:
task
- The task to run.
-
submitAsync
Submits the given work to be run synchronously on the main thread of the game.This method will
not be guarded against exceptions.
If you need to guard against exceptions, callCompletableFuture.exceptionally(Function)
,CompletableFuture.exceptionallyAsync(Function)
}, or derivatives on the returned future.- Parameters:
task
- The task to run.- Returns:
- A future which will complete when the task has been run.
-