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 FunctionState
awaitOnAsset(FunctionState function)
Flags for theFunctionState
(and more specifically theThreadState
of theFunctionState
) to wait until theAsset
is ready.void
failFunctions(java.lang.Throwable failure, boolean isPermanent)
Fails theFunctionState
instances waiting on thisAsset
.Asset
getAsset()
Obtains theAsset
for thisAssetLatch
.AssetManager
getLinkedListSetOwner()
Obtains the owner of theLinkedListSet
that thisLinkedListSetEntry
may be added.long
getTime()
Obtains the time that check is being made.void
releaseFunctions(boolean isPermanent)
Releases theFunctionState
instances waiting on theAsset
.void
releaseFunctions(boolean isPermanent, FunctionState functionState)
Releases theFunctionState
instances 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
-Asset
to be managed.assetManager
-AssetManager
for managing this.clock
-MonitorClock
.
-
-
Method Detail
-
getLinkedListSetOwner
public AssetManager getLinkedListSetOwner()
Description copied from interface:LinkedListSetEntry
Obtains the owner of the
LinkedListSet
that thisLinkedListSetEntry
may be added.LinkedListSetEntry
instances may only be added to theLinkedListSet
they were intended for and can not be shared betweenLinkedListSet
instances. This constraint:- ensures the integrity of the
FunctionState
,Flow
,ThreadState
,ProcessState
structure, and - improves uniqueness performance as
LinkedListSetEntry.getNext()
andLinkedListSetEntry.getPrev()
both returningnull
indicates not added
- Specified by:
getLinkedListSetOwner
in interfaceLinkedListSetEntry<AssetLatchImpl,AssetManager>
- Returns:
- Owner of the
LinkedListSet
that may contain thisLinkedListSetEntry
.
- ensures the integrity of the
-
getAsset
public Asset getAsset()
Description copied from interface:AssetLatch
Obtains theAsset
for thisAssetLatch
.- Specified by:
getAsset
in interfaceAssetLatch
- Returns:
Asset
for thisAssetLatch
.
-
awaitOnAsset
public FunctionState awaitOnAsset(FunctionState function)
Description copied from interface:AssetLatch
Flags for the
FunctionState
(and more specifically theThreadState
of theFunctionState
) to wait until theAsset
is ready.This is typically because the
Asset
is doing some processing that theFunctionState
requires completed before proceeding.- Specified by:
awaitOnAsset
in interfaceAssetLatch
- Parameters:
function
-FunctionState
to be released when theAsset
is ready.- Returns:
- Optional
FunctionState
to execute to wait on theAsset
.
-
getTime
public long getTime()
Description copied from interface:CheckAssetContext
Obtains the time that check is being made.
As many
Asset
instances 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 checkingAsset
timeouts).- Specified by:
getTime
in interfaceCheckAssetContext
- Returns:
System.currentTimeMillis()
equivalent for checkingAsset
timeouts.
-
releaseFunctions
public void releaseFunctions(boolean isPermanent)
Description copied from interface:AssetLatch
Releases theFunctionState
instances waiting on theAsset
.- Specified by:
releaseFunctions
in interfaceAssetLatch
- Specified by:
releaseFunctions
in interfaceCheckAssetContext
- Parameters:
isPermanent
-true
indicates that allFunctionState
instances added to theAssetLatch
from now on are activated immediately. It is useful to flag anAssetLatch
in this state when theAsset
is no longer being used to stop aFunctionState
from waiting forever.
-
releaseFunctions
public void releaseFunctions(boolean isPermanent, FunctionState functionState)
Description copied from interface:AssetLatch
Releases theFunctionState
instances waiting on theAsset
.- Specified by:
releaseFunctions
in interfaceAssetLatch
- Parameters:
isPermanent
-true
indicates that allFunctionState
instances added to theAssetLatch
from now on are activated immediately. It is useful to flag anAssetLatch
in this state when theAsset
is no longer being used to stop aFunctionState
from waiting forever.functionState
-FunctionState
to be executed first before each currently waitingFunctionState
.
-
failFunctions
public void failFunctions(java.lang.Throwable failure, boolean isPermanent)
Description copied from interface:AssetLatch
Fails theFunctionState
instances waiting on thisAsset
.- Specified by:
failFunctions
in interfaceAssetLatch
- Specified by:
failFunctions
in interfaceCheckAssetContext
- Parameters:
failure
- Failure to propagate to theThreadState
of theFunctionState
instances waiting on theAsset
.isPermanent
-true
indicates that allFunctionState
instances added to theAssetLatch
from now on are activated immediately with the input failure. It is useful to flag anAssetLatch
in this state when theAsset
is in a failed state that can not be recovered from.
-
-