Class PollingFuture<V>
java.lang.Object
com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
com.inductiveautomation.ignition.common.execution.PollingFuture<V>
- Direct Known Subclasses:
- PerspectivePollingFuture
Scaffolding for managing the fetching of a completable future that may need to poll or be executed on-demand.
- 
Nested Class SummaryNested Classes
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionPollingFuture(ScheduledExecutorService scheduler, ExecutorService executor, Supplier<CompletableFuture<V>> fetch, BiConsumer<V, Throwable> whenComplete, long rate, TimeUnit rateTimeUnit, String diagnosticId) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected longDefault implementation returns the rate from the constructor, but provides a place for subclasses to re-define the rate on startup if necessary.longprotected voidprotected voidvoidvoidSubmits the task immediately if currently idle or scheduled.Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycleisRunning, shutdown, startup
- 
Field Details- 
LOG
 
- 
- 
Constructor Details- 
PollingFuturepublic PollingFuture(ScheduledExecutorService scheduler, ExecutorService executor, Supplier<CompletableFuture<V>> fetch, BiConsumer<V, Throwable> whenComplete, long rate, TimeUnit rateTimeUnit, String diagnosticId) - Parameters:
- scheduler- No blocking work will be done on this scheduler
- executor- Value delivery will be done on this executor
- fetch- Fetch the next value. Don't block.
- whenComplete- Callback for when the value is received. May block. Will be called on the executor.
- rate- If positive, the task will be executed once on startup, and then repeatedly with this amount of time as a delay between executions. If zero or less, will be executed once on startup, and again whenever- submitIfIdle()is called.
- rateTimeUnit- Time unit for the rate.
- diagnosticId- Will be set during task execution using MDC as "task-id" key
 
 
- 
- 
Method Details- 
submitIfIdlepublic void submitIfIdle()Submits the task immediately if currently idle or scheduled.
- 
getInitialRateprotected long getInitialRate()Default implementation returns the rate from the constructor, but provides a place for subclasses to re-define the rate on startup if necessary.
- 
onStartupprotected void onStartup()- Specified by:
- onStartupin class- AbstractLifecycle
 
- 
onShutdownprotected void onShutdown()- Specified by:
- onShutdownin class- AbstractLifecycle
 
- 
setRate
- 
getRateMillispublic long getRateMillis()
 
-