public abstract class RecordProcessor extends Object
Executor
.
Classes that extend RecordProcessor
listen for incoming records and process them in
separate thread or threads.
Executor
may be single thread or thread pool executor. One Executor
may be shared by different record processors.
It is guaranteed that new processing handler will not be called until previous has completed its work.
RecordProcessor
registers RecordListener
in RecordProvider
when
startProcessing(RecordProvider)
startProcessing} 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 |
RecordProcessor(Executor executor)
Constructs new record processor for the specified executor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasMoreToProcess()
Returns true when this RecordProcessor has more records available to process or its
task is scheduled for processing.
|
protected abstract void |
process(RecordSource source)
Method for processing incoming records.
|
protected void |
signalNoMoreToProcess()
This method is called immediately before
hasMoreToProcess() becomes false. |
void |
startProcessing(RecordProvider provider)
Starts processing for the specified
RecordProvider . |
void |
stopProcessing()
Stops processing.
|
protected RecordProcessor(Executor executor)
NullPointerException
- if executor is null.protected abstract void process(RecordSource source)
RecordProcessor
calls this method in Executor
thread.public void startProcessing(RecordProvider provider)
RecordProvider
.
This method may be called at most once after construction.NullPointerException
- if provider
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 stopProcessing()
RecordListener
on RecordProvider
.
This method may be called only after startProcessing(RecordProvider)
.
Note: client code is responsible for disposing RecordProvider originally passed to RecordProcessor.IllegalStateException
- if called before startProcessing(RecordProvider)
.public boolean hasMoreToProcess()
protected void signalNoMoreToProcess()
hasMoreToProcess()
becomes false.Copyright © 2002–2025 Devexperts LLC. All rights reserved.