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
ConstructorsConstructorDescriptionModelFarmOnDemand(int nThreads, Model<DATATYPE> model) Create a multithreaded resource to execute data driven models on demand. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidexecute()Executes the next task in the work queue.protected booleanReturns true if the model farm queue is empty and false if the queue contains elements to execute.protected voidMethod called after the model farm threads have been started.voidrequestUpdate(ROWDATAMANAGERTYPE dataManager, Runnable callback) Submit a request toexecutetheModelFarmBase.model.voidrequestUpdate(ROWDATAMANAGERTYPE dataManager, Runnable callback, Set<KEYTYPE> keys) Submit a request toexecutetheModelFarmBase.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 toexecutetheModelFarmBase.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 thedataManagerwill be processed.- Parameters:
dataManager- TheRowDataManagerthat 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 toexecutetheModelFarmBase.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- TheRowDataManagerthat 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 thedataManagerwill be processed.
-
execute
Description copied from class:ModelFarmBaseExecutes the next task in the work queue.- Specified by:
executein classModelFarmBase<DATATYPE>- Throws:
InterruptedException- if interrupted while executing
-
modelFarmStarted
protected void modelFarmStarted()Description copied from class:ModelFarmBaseMethod 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:
modelFarmStartedin classModelFarmBase<DATATYPE>
-
isQueueEmpty
protected boolean isQueueEmpty()Description copied from class:ModelFarmBaseReturns true if the model farm queue is empty and false if the queue contains elements to execute.- Specified by:
isQueueEmptyin classModelFarmBase<DATATYPE>- Returns:
- true if the model farm queue is empty and false if the queue contains elements to execute.
-