Class ContinuationConfigRuntime
The active runtime configuration always has to be available through
getActiveConfigRuntime()
when a continuable object is
executed. Therefore, it's best to always call
setActiveConfigRuntime(rife.continuations.ContinuationConfigRuntime)
before the execution. The
BasicContinuableRunner
does
this by default. If you create your own runner, you have to ensure that
this is respected.
By default the lifetime duration and purging of continuable object instances is set to a sensible default, so this only needs tuning in specific case.
This class has to be extended though to provide information that suits your continuations usage and to indicate whether continuations should be cloned when they are resumed.
- Since:
- 1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Removes active runtime configuration for the executing thread.abstract boolean
cloneContinuations
(Object executingContinuable) Indicates whether a continuable should be cloned before resuming the execution.static ContinuationConfigRuntime
Retrieves the active runtime configuration for the executing thread.long
The duration, in milliseconds, by which a continuation stays valid.abstract ContinuationManager
getContinuationManager
(Object executingInstance) Retrieves the manager that is responsible for the continuable object that is currently executing.int
The frequency by which the continuations purging will run in theContinuationManager
.int
The scale that will be used to determine how often continuations purging will run in theContinuationManager
.static void
Sets the active runtime configuration for the executing thread.
-
Constructor Details
-
ContinuationConfigRuntime
public ContinuationConfigRuntime()
-
-
Method Details
-
setActiveConfigRuntime
Sets the active runtime configuration for the executing thread.- Parameters:
config
- the active runtime configuration for the executing thread- Since:
- 1.0
-
clearActiveConfigRuntime
public static void clearActiveConfigRuntime()Removes active runtime configuration for the executing thread.- Since:
- 1.6.1
-
getActiveConfigRuntime
public static ContinuationConfigRuntime getActiveConfigRuntime() throws MissingActiveContinuationConfigRuntimeExceptionRetrieves the active runtime configuration for the executing thread.- Returns:
- the active runtime configuration
- Throws:
MissingActiveContinuationConfigRuntimeException
- when the active runtime configuration isn't set- Since:
- 1.0
-
getContinuationDuration
public long getContinuationDuration()The duration, in milliseconds, by which a continuation stays valid.When this period is exceeded, a continuation can not be retrieved anymore, and it will be removed from the manager during the next purge.
- Returns:
- the validity duration of a continuation in milliseconds
- Since:
- 1.0
-
getContinuationPurgeFrequency
public int getContinuationPurgeFrequency()The frequency by which the continuations purging will run in theContinuationManager
.This works together with the scale that is configured through
getContinuationPurgeScale()
. The frequency divided by the scale makes how often the purging will happen. For instance, a frequency of 20 and a scale of 1000 means that purging will happen 1/50th of the time.- Returns:
- the continuation purge frequency
- Since:
- 1.0
- See Also:
-
getContinuationPurgeScale
public int getContinuationPurgeScale()The scale that will be used to determine how often continuations purging will run in theContinuationManager
.See
getContinuationPurgeFrequency()
for more info.- Returns:
- the continuation purge scale
- Since:
- 1.0
- See Also:
-
getContinuationManager
Retrieves the manager that is responsible for the continuable object that is currently executing.- Parameters:
executingInstance
- the currently executing object instance- Returns:
- the corresponding manager
- Since:
- 1.0
-
cloneContinuations
Indicates whether a continuable should be cloned before resuming the execution.- Parameters:
executingContinuable
- the currently executing continuable- Returns:
true
is the continuation should be cloned; orfalse
otherwise- Since:
- 1.0
-