Class RecordPipe

java.lang.Object
com.kingsrook.qqq.backend.core.actions.reporting.RecordPipe
Direct Known Subclasses:
BufferedRecordPipe, DistinctFilteringRecordPipe

public class RecordPipe extends Object
Object to connect a producer of records with a consumer. Best for those to be on different threads, to avoid deadlock.
  • Constructor Details

    • RecordPipe

      public RecordPipe()
      Default constructor.
    • RecordPipe

      public RecordPipe(Integer overrideCapacity)
      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

      public void addRecord(QRecord record) throws QException
      Add a record to the pipe. Will block if the pipe is full. Will noop if pipe is terminated.
      Throws:
      QException
    • addRecords

      public void addRecords(List<QRecord> records) throws QException
      Add a list of records to the pipe. Will block if the pipe is full. Will noop if pipe is terminated.
      Throws:
      QException
    • consumeAvailableRecords

      public List<QRecord> consumeAvailableRecords()
    • countAvailableRecords

      public int countAvailableRecords()
    • setPostRecordActions

      public void setPostRecordActions(UnsafeConsumer<List<QRecord>,QException> postRecordActions)
    • getCapacity

      public int getCapacity()
      Getter for capacity