Package io.deephaven.modelfarm
Class ModelFarmOnDemand<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE extends RowDataManager<KEYTYPE,DATATYPE>>
java.lang.Object
io.deephaven.modelfarm.ModelFarmBase<DATATYPE>
io.deephaven.modelfarm.ModelFarmOnDemand<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE>
- Type Parameters:
KEYTYPE
- The type of keys.DATATYPE
- The type of data.ROWDATAMANAGERTYPE
- The type of RowDataManager.
- All Implemented Interfaces:
ModelFarm
public class ModelFarmOnDemand<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE extends RowDataManager<KEYTYPE,DATATYPE>>
extends ModelFarmBase<DATATYPE>
A ModelFarm implementation for evaluating a model upon request, retrieving a snapshot of data for all keys under a
single
PeriodicUpdateGraph
lock.-
Nested Class Summary
Nested classes/interfaces inherited from class io.deephaven.modelfarm.ModelFarmBase
ModelFarmBase.GetDataLockType, ModelFarmBase.State
-
Field Summary
Fields inherited from class io.deephaven.modelfarm.ModelFarmBase
model
-
Constructor Summary
ConstructorDescriptionModelFarmOnDemand
(int nThreads, Model<DATATYPE> model) Create a multithreaded resource to execute data driven models on demand. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
execute()
Executes the next task in the work queue.protected boolean
Returns true if the model farm queue is empty and false if the queue contains elements to execute.protected void
Method called after the model farm threads have been started.void
requestUpdate
(ROWDATAMANAGERTYPE dataManager, Runnable callback) Submit a request toexecute
theModelFarmBase.model
.void
requestUpdate
(ROWDATAMANAGERTYPE dataManager, Runnable callback, Set<KEYTYPE> keys) Submit a request toexecute
theModelFarmBase.model
.Methods inherited from class io.deephaven.modelfarm.ModelFarmBase
awaitTermination, awaitTermination, getDoLockedConsumer, getState, shutdown, shutdownAndAwaitTermination, shutdownAndAwaitTermination, start, terminate, toString
-
Constructor Details
-
ModelFarmOnDemand
Create a multithreaded resource to execute data driven models on demand.- Parameters:
nThreads
- number of worker threads.model
- model to execute.
-
-
Method Details
-
requestUpdate
Submit a request toexecute
theModelFarmBase.model
. Can be called either with or without a PeriodicUpdateGraph lock -- the decision of whether/how to acquire a lock is left to theDO_LOCKED_FUNCTION
. All keys represented by the data in thedataManager
will be processed.- Parameters:
dataManager
- TheRowDataManager
that will provide data for the pricing requests.callback
- A callback function to run after all keys have been processed. Can benull
, in which case it will be ignored.
-
requestUpdate
Submit a request toexecute
theModelFarmBase.model
. Can be called either with or without a PeriodicUpdateGraph lock -- the decision of whether/how to acquire a lock is left to theDO_LOCKED_FUNCTION
.- Parameters:
dataManager
- TheRowDataManager
that will provide data for the pricing requests.callback
- A callback function to run after all keys have been processed. Can benull
, in which case it will be ignored.keys
- They keys for which data should be passed to the model. Ifkeys == null
, then all keys represented by the data in thedataManager
will be processed.
-
execute
Description copied from class:ModelFarmBase
Executes the next task in the work queue.- Specified by:
execute
in classModelFarmBase<DATATYPE>
- Throws:
InterruptedException
- if interrupted while executing
-
modelFarmStarted
protected void modelFarmStarted()Description copied from class:ModelFarmBase
Method called after the model farm threads have been started. Implementing classes can override this to perform additional setup (e.g. creating and starting listeners). The default implementation does nothing.- Specified by:
modelFarmStarted
in classModelFarmBase<DATATYPE>
-
isQueueEmpty
protected boolean isQueueEmpty()Description copied from class:ModelFarmBase
Returns true if the model farm queue is empty and false if the queue contains elements to execute.- Specified by:
isQueueEmpty
in classModelFarmBase<DATATYPE>
- Returns:
- true if the model farm queue is empty and false if the queue contains elements to execute.
-