Class RecordPipe
java.lang.Object
com.kingsrook.qqq.backend.core.actions.reporting.RecordPipe
- Direct Known Subclasses:
BufferedRecordPipe
,DistinctFilteringRecordPipe
Object to connect a producer of records with a consumer.
Best for those to be on different threads, to avoid deadlock.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.RecordPipe
(Integer overrideCapacity) Construct a record pipe, with an alternative capacity for the internal queue. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a record to the pipe.void
addRecords
(List<QRecord> records) Add a list of records to the pipe.int
int
Getter for capacityvoid
setPostRecordActions
(UnsafeConsumer<List<QRecord>, QException> postRecordActions) void
Turn off the pipe.
-
Constructor Details
-
RecordPipe
public RecordPipe()Default constructor. -
RecordPipe
Construct a record pipe, with an alternative capacity for the internal queue. overrideCapacity is allowed to be null - in which case, DEFAULT_CAPACITY is used.
-
-
Method Details
-
terminate
public void terminate()Turn off the pipe. Stop accepting new records (just ignore them in the add method). Clear the existing queue. Don't return any more records. Note that if consumeAvailableRecords was running in another thread, it may still return some records that it read before this call. -
addRecord
Add a record to the pipe. Will block if the pipe is full. Will noop if pipe is terminated.- Throws:
QException
-
addRecords
Add a list of records to the pipe. Will block if the pipe is full. Will noop if pipe is terminated.- Throws:
QException
-
consumeAvailableRecords
-
countAvailableRecords
public int countAvailableRecords() -
setPostRecordActions
-
getCapacity
public int getCapacity()Getter for capacity
-