Package de.linusdev.lutils.thready.var
Class SyncVarImpl<T>
java.lang.Object
de.linusdev.lutils.thready.var.SyncVarImpl<T>
- All Implemented Interfaces:
SyncVar<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanconsumeIfNotNull(@NotNull Consumer<@NotNull T> consumer) locks on this variable and checks if its value is notnull.voiddoSynchronised(@NotNull Consumer<@NotNull SyncVar<T>> consumer) Execute givenconsumersynchronised on this variable.get()Synchronised get.voidSynchronised set.booleanSame asSyncVar.setIfNull(Object)but with aSupplier.booleanSets the variables value if it isnull.
-
Constructor Details
-
SyncVarImpl
-
-
Method Details
-
get
Description copied from interface:SyncVarSynchronised get. -
doSynchronised
Description copied from interface:SyncVarExecute givenconsumersynchronised on this variable.- Specified by:
doSynchronisedin interfaceSyncVar<T>- Parameters:
consumer-Consumer
-
consumeIfNotNull
Description copied from interface:SyncVarlocks on this variable and checks if its value is notnull. If that is the case, givenconsumerwill be executed, while keeping the lock on the variable.- Specified by:
consumeIfNotNullin interfaceSyncVar<T>- Parameters:
consumer- to consume the variable- Returns:
trueif givenconsumerwas executed.falseotherwise.
-
setIfNull
Description copied from interface:SyncVarSets the variables value if it isnull. thread safe. -
setIfNull
Description copied from interface:SyncVarSame asSyncVar.setIfNull(Object)but with aSupplier. -
set
Description copied from interface:SyncVarSynchronised set.
-