public abstract class SubscriptionProcessor extends Object
Executor
.
Classes which extends SubscriptionProcessor
listen for subscription coming from QD and process incoming subscription
in separate thread or threads.
Executor
may be single thread or thread pool executor. One Executor may be shared by different subscription processors.
It is guaranteed that new subscription processing handler will not be called until previous has completed its work.
SubscriptionProcessor
registers RecordListener
in all RecordProvider
instances when
startProcessing(com.devexperts.qd.QDDistributor)
method is called.
Class client is responsible to call stopProcessing()
when processing is not required any more.
This class is thread-safe and lock-free. Change carefully.Modifier | Constructor and Description |
---|---|
protected |
SubscriptionProcessor(Executor executor,
QDContract contract)
Constructs new subscription processor for the specified executor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasMoreToProcess()
Returns true when this SubscriptionProcessor has more subscription available to process or its
task is scheduled for processing.
|
protected abstract void |
processAddedSubscription(RecordSource source)
Method for processing incoming added subscription from QD.
|
protected abstract void |
processRemovedSubscription(RecordSource source)
Method for processing incoming removed subscription from QD.
|
protected void |
signalNoMoreToProcess()
This method is called immediately before
hasMoreToProcess() becomes false. |
void |
startProcessing(QDDistributor distributor)
Starts subscription processing for the specified
QDDistributor . |
void |
startProcessing(RecordProvider addedSubscriptionProvider,
RecordProvider removedSubscriptionProvider)
Starts subscription processing for the specified added and removed
RecordProvider instances. |
void |
stopProcessing()
Stop subscription processing.
|
protected SubscriptionProcessor(Executor executor, QDContract contract)
executor
- the executor.contract
- the contract for which subscription shall be processed.NullPointerException
- if executor is null.protected abstract void processAddedSubscription(RecordSource source)
SubscriptionProcessor
calls this method in Executor
thread.protected abstract void processRemovedSubscription(RecordSource source)
SubscriptionProcessor
calls this method in Executor
thread.public void startProcessing(QDDistributor distributor)
QDDistributor
.
This method is equivalent to the following code:
startProcessing(distributor.getAddedRecordProvider(), distributor.getRemovedRecordProvider())
.
This method or startProcessing(RecordProvider, RecordProvider)
may be called at most once after construction.NullPointerException
- if distributor is null.IllegalStateException
- if called multiple times. It is checked weakly to ensure fail-fast error detection
behaviour. There is no strict thread-safe guarantee for this exception to be thrown if this method is called
concurrently from multiple threads.public void startProcessing(RecordProvider addedSubscriptionProvider, RecordProvider removedSubscriptionProvider)
RecordProvider
instances.
This method accepts null
for one of the providers.
This method or startProcessing(QDDistributor)
may be called at most once after construction.NullPointerException
- if both RecordProvider
arguments are null
.IllegalStateException
- if called multiple times. It is checked weakly to ensure fail-fast error detection
behaviour. There is no strict thread-safe guarantee for this exception to be thrown if this method is called
concurrently from multiple threads.public void stopProcessing()
RecordProvider
instances from RecordProvider
instances.
Note: client code is responsible for disposing SubscriptionProviders originally passed to SubscriptionProcessor.IllegalStateException
- if called before startProcessing(QDDistributor)
or
startProcessing(RecordProvider, RecordProvider)
.public boolean hasMoreToProcess()
protected void signalNoMoreToProcess()
hasMoreToProcess()
becomes false.Copyright © 2002–2025 Devexperts LLC. All rights reserved.