Record Class NetworkRegistry.EventLoopSynchronizedWorkHandler<T>
java.lang.Object
java.lang.Record
net.neoforged.neoforge.network.registration.NetworkRegistry.EventLoopSynchronizedWorkHandler<T>
- Record Components:
eventLoop
- The event loop to schedule tasks on.
- All Implemented Interfaces:
ISynchronizedWorkHandler
- Enclosing class:
- NetworkRegistry
private static record NetworkRegistry.EventLoopSynchronizedWorkHandler<T>(ReentrantBlockableEventLoop<?> eventLoop, T payload)
extends Record
implements ISynchronizedWorkHandler
An
ISynchronizedWorkHandler
that can be used to schedule tasks on the main thread of the server or client. This wrapper record is used to line up the APIs of the ReentrantBlockableEventLoop
with the ISynchronizedWorkHandler
.-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
EventLoopSynchronizedWorkHandler
(ReentrantBlockableEventLoop<?> eventLoop, T payload) Creates an instance of aEventLoopSynchronizedWorkHandler
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.Returns the value of theeventLoop
record component.void
Executes a task on the main thread of the game.final int
hashCode()
Returns a hash code value for this object.payload()
Returns the value of thepayload
record component.submitAsync
(Runnable task) Submits the given work to be run synchronously on the main thread of the game.<R> CompletableFuture<R>
submitAsync
(Supplier<R> task) Submits the given work to be run synchronously on the main thread of the game.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
eventLoop
The field for theeventLoop
record component. -
payload
The field for thepayload
record component. -
LOGGER
private static final org.slf4j.Logger LOGGER
-
-
Constructor Details
-
EventLoopSynchronizedWorkHandler
Creates an instance of aEventLoopSynchronizedWorkHandler
record class.- Parameters:
eventLoop
- the value for theeventLoop
record componentpayload
- the value for thepayload
record component
-
-
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.
- Specified by:
execute
in interfaceISynchronizedWorkHandler
- 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.- Specified by:
submitAsync
in interfaceISynchronizedWorkHandler
- 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.- Specified by:
submitAsync
in interfaceISynchronizedWorkHandler
- Parameters:
task
- The task to run.- Returns:
- A future which will complete when the task has been run.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
eventLoop
Returns the value of theeventLoop
record component.- Returns:
- the value of the
eventLoop
record component
-
payload
Returns the value of thepayload
record component.- Returns:
- the value of the
payload
record component
-