Interface AssetLatch
- All Known Implementing Classes:
AssetLatchImpl
public interface AssetLatch
Latch on an Asset to only allow the ThreadState instances
proceed when Asset is ready.
May be used as a LinkedListSetEntry in a list of AssetLatch
instances for an AssetManager.
- Author:
- Daniel Sagenschneider
-
Method Summary
Modifier and TypeMethodDescriptionawaitOnAsset(FunctionState function) Flags for theFunctionState(and more specifically theThreadStateof theFunctionState) to wait until theAssetis ready.voidfailFunctions(Throwable failure, boolean isPermanent) Fails theFunctionStateinstances waiting on thisAsset.getAsset()Obtains theAssetfor thisAssetLatch.voidreleaseFunctions(boolean isPermanent) Releases theFunctionStateinstances waiting on theAsset.voidreleaseFunctions(boolean isPermanent, FunctionState functionState) Releases theFunctionStateinstances waiting on theAsset.
-
Method Details
-
getAsset
Asset getAsset()Obtains theAssetfor thisAssetLatch.- Returns:
Assetfor thisAssetLatch.
-
awaitOnAsset
Flags for the
FunctionState(and more specifically theThreadStateof theFunctionState) to wait until theAssetis ready.This is typically because the
Assetis doing some processing that theFunctionStaterequires completed before proceeding.- Parameters:
function-FunctionStateto be released when theAssetis ready.- Returns:
- Optional
FunctionStateto execute to wait on theAsset.
-
releaseFunctions
void releaseFunctions(boolean isPermanent) Releases theFunctionStateinstances waiting on theAsset.- Parameters:
isPermanent-trueindicates that allFunctionStateinstances added to theAssetLatchfrom now on are activated immediately. It is useful to flag anAssetLatchin this state when theAssetis no longer being used to stop aFunctionStatefrom waiting forever.
-
releaseFunctions
Releases theFunctionStateinstances waiting on theAsset.- Parameters:
isPermanent-trueindicates that allFunctionStateinstances added to theAssetLatchfrom now on are activated immediately. It is useful to flag anAssetLatchin this state when theAssetis no longer being used to stop aFunctionStatefrom waiting forever.functionState-FunctionStateto be executed first before each currently waitingFunctionState.
-
failFunctions
Fails theFunctionStateinstances waiting on thisAsset.- Parameters:
failure- Failure to propagate to theThreadStateof theFunctionStateinstances waiting on theAsset.isPermanent-trueindicates that allFunctionStateinstances added to theAssetLatchfrom now on are activated immediately with the input failure. It is useful to flag anAssetLatchin this state when theAssetis in a failed state that can not be recovered from.
-