|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.devexperts.qd.util.SubscriptionProcessor
public abstract class SubscriptionProcessor
This class is base class for listening QD for subscription availability and rescheduling its processing using 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 SubscriptionListener
in all SubscriptionProvider
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.
Constructor Summary | |
---|---|
protected |
SubscriptionProcessor(java.util.concurrent.Executor executor)
Constructs new subscription processor for the specified executor. |
protected |
SubscriptionProcessor(java.util.concurrent.Executor executor,
QDDistributor distributor)
Deprecated. Usage of this method can lead to NullPointerException or other problems in extending code,
because this method starts processing and leaks this pointer to other threads (submits it to executor}
right from inside constructor. Derived classes that initialize their fields (including final ones) in constructor
may see default, non-initialized values of those fields. Use SubscriptionProcessor(Executor) and call
startProcessing(QDDistributor) method after construction. |
protected |
SubscriptionProcessor(java.util.concurrent.Executor executor,
SubscriptionProvider addedSubscriptionProvider,
SubscriptionProvider removedSubscriptionProvider)
Deprecated. Usage of this method can lead to NullPointerException or other problems in extending code,
because this method starts processing and leaks this pointer to other threads (submits it to executor}
right from inside constructor. Derived classes that initialize their fields (including final ones) in constructor
may see default, non-initialized values of those fields. Use SubscriptionProcessor(Executor) and call
startProcessing(SubscriptionProvider, SubscriptionProvider) method after construction. |
Method Summary | |
---|---|
protected abstract void |
processAddedSubscription(SubscriptionIterator iterator)
Method for processing incoming added subscription from QD. |
protected abstract void |
processRemovedSubscription(SubscriptionIterator iterator)
Method for processing incoming removed subscription from QD. |
void |
startProcessing(QDDistributor distributor)
Starts subscription processing for the specified QDDistributor . |
void |
startProcessing(SubscriptionProvider addedSubscriptionProvider,
SubscriptionProvider removedSubscriptionProvider)
Starts subscription processing for the specified added and removed SubscriptionProvider instances. |
void |
stopProcessing()
Stop subscription processing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected SubscriptionProcessor(java.util.concurrent.Executor executor, QDDistributor distributor)
NullPointerException
or other problems in extending code,
because this method starts processing and leaks this
pointer to other threads (submits it to executor}
right from inside constructor. Derived classes that initialize their fields (including final ones) in constructor
may see default, non-initialized values of those fields. Use SubscriptionProcessor(Executor)
and call
startProcessing(QDDistributor)
method after construction.
SubscriptionListener
s on subscription providers in
passed QDDistributor
s and start processing.
java.lang.NullPointerException
- if executor is null.protected SubscriptionProcessor(java.util.concurrent.Executor executor, SubscriptionProvider addedSubscriptionProvider, SubscriptionProvider removedSubscriptionProvider)
NullPointerException
or other problems in extending code,
because this method starts processing and leaks this
pointer to other threads (submits it to executor}
right from inside constructor. Derived classes that initialize their fields (including final ones) in constructor
may see default, non-initialized values of those fields. Use SubscriptionProcessor(Executor)
and call
startProcessing(SubscriptionProvider, SubscriptionProvider)
method after construction.
SubscriptionListener
s on passed SubscriptionProvider
s
and start processing. This constructor accepts null
for one of the subscription providers.
java.lang.NullPointerException
- if executor is null.protected SubscriptionProcessor(java.util.concurrent.Executor executor)
java.lang.NullPointerException
- if executor is null.Method Detail |
---|
protected abstract void processAddedSubscription(SubscriptionIterator iterator)
SubscriptionProcessor
calls this method in Executor
thread.
protected abstract void processRemovedSubscription(SubscriptionIterator iterator)
SubscriptionProcessor
calls this method in Executor
thread.
public void startProcessing(QDDistributor distributor)
QDDistributor
.
This method is equivalent to the following code:
startProcessing(distributor.getAddedSubscriptionProvider(), distributor.getRemovedSubscriptionProvider())
.
This method or startProcessing(SubscriptionProvider, SubscriptionProvider)
may be called at most once after construction.
java.lang.NullPointerException
- if distributor is null.
java.lang.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(SubscriptionProvider addedSubscriptionProvider, SubscriptionProvider removedSubscriptionProvider)
SubscriptionProvider
instances.
This method accepts null
for one of the subscription providers.
This method or startProcessing(QDDistributor)
may be called at most once after construction.
java.lang.NullPointerException
- if both SubscriptionProvider
arguments are null
.
java.lang.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()
SubscriptionListener
instances from SubscriptionProvider
instances.
Note: client code is responsible for disposing SubscriptionProviders originally passed to SubscriptionProcessor.
java.lang.IllegalStateException
- if called before startProcessing(QDDistributor)
or
startProcessing(SubscriptionProvider, SubscriptionProvider)
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |