Class BlockingMultiStreamConsumer<E>

    • Field Detail

      • _lastRead

        protected int _lastRead
        An index that used to calculate where do we are going to start reading. The invariant is that we are always going to start reading from _lastRead + 1. Therefore _lastRead must be in the range [-1, mailbox.size() - 1]
    • Constructor Detail

      • BlockingMultiStreamConsumer

        public BlockingMultiStreamConsumer​(Object id,
                                           long deadlineMs,
                                           List<? extends AsyncStream<E>> asyncProducers)
    • Method Detail

      • isError

        protected abstract boolean isError​(E element)
      • isEos

        protected abstract boolean isEos​(E element)
      • onTimeout

        protected abstract E onTimeout()
      • onException

        protected abstract E onException​(Exception e)
      • onEos

        protected abstract E onEos()
      • cancel

        public void cancel​(Throwable t)
      • cancelRemainingMailboxes

        protected void cancelRemainingMailboxes()
      • onData

        public void onData()
      • readBlockBlocking

        public E readBlockBlocking()
        Reads the next block for any ready mailbox or blocks until some of them is ready. The method implements a sequential read semantic. Meaning that:
        1. EOS is only returned when all mailboxes already emitted EOS or there are no mailboxes
        2. If an error is read from a mailbox, the error is returned
        3. If data is read from a mailbox, that data block is returned
        4. If no mailbox is ready, the calling thread is blocked
        Right now the implementation tries to be fair. If one call returned the block from mailbox i, then next call will look for mailbox i+1, i+2... in a circular manner. In order to unblock a thread blocked here, onData() should be called. *