Class AssetLatchImpl
- java.lang.Object
-
- net.officefloor.frame.impl.execute.linkedlistset.AbstractLinkedListSetEntry<AssetLatchImpl,AssetManager>
-
- net.officefloor.frame.impl.execute.asset.AssetLatchImpl
-
- All Implemented Interfaces:
AssetLatch,CheckAssetContext,LinkedListSetEntry<AssetLatchImpl,AssetManager>
public class AssetLatchImpl extends AbstractLinkedListSetEntry<AssetLatchImpl,AssetManager> implements AssetLatch, CheckAssetContext
Implementation of theAssetLatch.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description AssetLatchImpl(Asset asset, AssetManagerImpl assetManager, MonitorClock clock)Initiate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FunctionStateawaitOnAsset(FunctionState function)Flags for theFunctionState(and more specifically theThreadStateof theFunctionState) to wait until theAssetis ready.voidfailFunctions(java.lang.Throwable failure, boolean isPermanent)Fails theFunctionStateinstances waiting on thisAsset.AssetgetAsset()Obtains theAssetfor thisAssetLatch.AssetManagergetLinkedListSetOwner()Obtains the owner of theLinkedListSetthat thisLinkedListSetEntrymay be added.longgetTime()Obtains the time that check is being made.voidreleaseFunctions(boolean isPermanent)Releases theFunctionStateinstances waiting on theAsset.voidreleaseFunctions(boolean isPermanent, FunctionState functionState)Releases theFunctionStateinstances waiting on theAsset.-
Methods inherited from class net.officefloor.frame.impl.execute.linkedlistset.AbstractLinkedListSetEntry
getNext, getPrev, setNext, setPrev
-
-
-
-
Constructor Detail
-
AssetLatchImpl
public AssetLatchImpl(Asset asset, AssetManagerImpl assetManager, MonitorClock clock)
Initiate.- Parameters:
asset-Assetto be managed.assetManager-AssetManagerfor managing this.clock-MonitorClock.
-
-
Method Detail
-
getLinkedListSetOwner
public AssetManager getLinkedListSetOwner()
Description copied from interface:LinkedListSetEntryObtains the owner of the
LinkedListSetthat thisLinkedListSetEntrymay be added.LinkedListSetEntryinstances may only be added to theLinkedListSetthey were intended for and can not be shared betweenLinkedListSetinstances. This constraint:- ensures the integrity of the
FunctionState,Flow,ThreadState,ProcessStatestructure, and - improves uniqueness performance as
LinkedListSetEntry.getNext()andLinkedListSetEntry.getPrev()both returningnullindicates not added
- Specified by:
getLinkedListSetOwnerin interfaceLinkedListSetEntry<AssetLatchImpl,AssetManager>- Returns:
- Owner of the
LinkedListSetthat may contain thisLinkedListSetEntry.
- ensures the integrity of the
-
getAsset
public Asset getAsset()
Description copied from interface:AssetLatchObtains theAssetfor thisAssetLatch.- Specified by:
getAssetin interfaceAssetLatch- Returns:
Assetfor thisAssetLatch.
-
awaitOnAsset
public FunctionState awaitOnAsset(FunctionState function)
Description copied from interface:AssetLatchFlags 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.- Specified by:
awaitOnAssetin interfaceAssetLatch- Parameters:
function-FunctionStateto be released when theAssetis ready.- Returns:
- Optional
FunctionStateto execute to wait on theAsset.
-
getTime
public long getTime()
Description copied from interface:CheckAssetContextObtains the time that check is being made.
As many
Assetinstances may be checked at the same time (or nanoseconds from each other) this provides optimisation to obtain the current time in milliseconds (equivalent toSystem.currentTimeMillis()for purpose of checkingAssettimeouts).- Specified by:
getTimein interfaceCheckAssetContext- Returns:
System.currentTimeMillis()equivalent for checkingAssettimeouts.
-
releaseFunctions
public void releaseFunctions(boolean isPermanent)
Description copied from interface:AssetLatchReleases theFunctionStateinstances waiting on theAsset.- Specified by:
releaseFunctionsin interfaceAssetLatch- Specified by:
releaseFunctionsin interfaceCheckAssetContext- 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
public void releaseFunctions(boolean isPermanent, FunctionState functionState)Description copied from interface:AssetLatchReleases theFunctionStateinstances waiting on theAsset.- Specified by:
releaseFunctionsin interfaceAssetLatch- 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
public void failFunctions(java.lang.Throwable failure, boolean isPermanent)Description copied from interface:AssetLatchFails theFunctionStateinstances waiting on thisAsset.- Specified by:
failFunctionsin interfaceAssetLatch- Specified by:
failFunctionsin interfaceCheckAssetContext- 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.
-
-