Internal method. See if we need to prefetch more messages, and if yes, do the prefetch
190166
private final void tryPrefetching() throws SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(this, tc, "tryPrefetching");
    int toPrefetchCount = 0; // count of gets to issue
    synchronized (this)
    {
      if (!detached)
      {
        int count = countOfOutstandingInfiniteTimeoutGets + countOfUnlockedMessages;

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(tc, "readAhead check: count(" + count + ") prefetchWindowSize(" + prefetchWindowSize + ")");
            	
        if (count < prefetchWindowSize) // note that it is possible that count > prefetchWindowSize
        {
          // perhaps we should prefetch
          if ( ((prefetchWindowSize - count)/(double) prefetchWindowSize) > SIMPConstants.MIN_PREFETCH_SIZE)
          {
            toPrefetchCount = prefetchWindowSize - count;
            countOfOutstandingInfiniteTimeoutGets += toPrefetchCount;
            
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(tc, "readAhead change: countOfOutstandingInfiniteTimeoutGets+= " + countOfOutstandingInfiniteTimeoutGets);
          }
        }
      }
    }

    if (toPrefetchCount > 0)
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        SibTr.debug(tc, "readAhead change: toPrefetchCount " + toPrefetchCount);
        
      AIStreamKey[] keys = rcd.issueGet(criteria, toPrefetchCount, this);
      int i;
      if (keys == null)
        i = 0;
      else
        i = keys.length;
      if (i < toPrefetchCount)
      {
        // this will be very rare!

        // decrement the counts.
        synchronized (this)
        {
          countOfOutstandingInfiniteTimeoutGets -= (toPrefetchCount -i); // the first i gets were successful
          
          if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(tc, "readAhead change: countOfOutstandingInfiniteTimeoutGets-= " + countOfOutstandingInfiniteTimeoutGets);
        }
        // log and throw exception to consumer
        SIResourceException e = new SIResourceException(
          nls.getFormattedMessage("ANYCAST_STREAM_UNAVAILABLE_CWSIP0481",
                                  new Object[]{rcd.getDestName(), rcd.getLocalisationUuid().toString()},
                                  null));
        FFDCFilter.processException(e,"com.ibm.ws.sib.processor.impl.RemoteQPConsumerKey.tryPrefetching",
            "1:755:1.47.1.26",this);
        SibTr.exception(tc, e);

        consumerPoint.notifyException(e);

      }
    } // end if (toPrefetchCount > 0)

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(this, tc, "tryPrefetching");
  }
157466
private void ensureFetching(long blockIndex) {
    if (fetching != null) {
      if (fetching.futureBuf.isDone()) {
        full.add(fetching);
        fetching = null;
      } else {
        return;
      }
    }
    for (WorkUnit w : full) {
      if (w.blockIndex == blockIndex) {
        return;
      }
    }
    if (full.size() < BUF_COUNT) {
      fetching = new WorkUnit(chan, bufSize, blockIndex);
    } else {
      // reuse the oldest full buffer
      fetching = full.remove(0);
      fetching.resetForIndex(blockIndex);
    }
    bytesRead += bufSize;
    fetching.futureBuf = exec.submit(fetching);
  }
1070256
@Override
	public boolean hasMoreElements()
	{
		if (endOfQueueReached)
			return false;
		try
		{
			checkNotClosed();
			Message msg = fetchNext();
			return msg != null;
		}
		catch (JMSException e)
		{
			throw new IllegalStateException(e.toString());
		}
	}
1249910
private synchronized void onContextReady(final ContextStatusPOJO contextStatus,
                                           final boolean notifyClientOnNewActiveContext) {
    assert ContextState.READY == contextStatus.getContextState();
    final String contextID = contextStatus.getContextId();
    // This could be the first message we get from that context
    if (this.isUnknownContextId(contextID)) {
      this.onNewContext(contextStatus, notifyClientOnNewActiveContext);
    }

    // Dispatch the messages to the application, if there are any.
    for (final ContextMessagePOJO
             contextMessage : contextStatus.getContextMessageList()) {
      final byte[] theMessage = contextMessage.getMessage();
      final String sourceID = contextMessage.getSourceId();
      final long sequenceNumber = contextMessage.getSequenceNumber();
      this.messageDispatcher.onContextMessage(new ContextMessageImpl(theMessage, contextID, sourceID, sequenceNumber));
    }

  }
265192
@Override
    public boolean hasNext() {
        if(next != null){
            return true;
        }
        if(!recordReader.hasNext()){
            return false;
        }

        //Prefetch, until we find one that isn't filtered out - or we run out of data
        while(next == null && recordReader.hasNext()){
            Record r = recordReader.nextRecord();
            List<Writable> temp = transformProcess.execute(r.getRecord());
            if(temp == null){
                continue;
            }
            next = new org.datavec.api.records.impl.Record(temp, r.getMetaData());
        }

        return next != null;
    }
1160853
private void displayMsg() {
        if (msgQueue.isEmpty()) {
            return;
        }
        // First peek whether the AppMsg is being displayed.
        final AppMsg appMsg = msgQueue.peek();
        final Message msg;
        if (!appMsg.isShowing()) {
            // Display the AppMsg
            msg = obtainMessage(MESSAGE_ADD_VIEW);
            msg.obj = appMsg;
            sendMessage(msg);
        } else if (appMsg.getDuration() != LENGTH_STICKY) {
            msg = obtainMessage(MESSAGE_DISPLAY);
            sendMessageDelayed(msg, appMsg.getDuration()
                    + appMsg.mInAnimation.getDuration() + appMsg.mOutAnimation.getDuration());
        }
    }
1010285
def load_thread_for_message m, opts={}
    good = @index.each_message_in_thread_for m, opts do |mid, builder|
      next if contains_id? mid
      add_message builder.call
    end
    add_message m if good
  end
870164
def next(self):
        
        if not self._messages:
            if self.auto_delete:
                self.delete_messages()
            raise StopIteration

        message = self._messages.pop(0)
        self._processed_messages.append(message)
        return json.loads(message.payload)
848852
def add_messages(self, messages):
        
        # remove old messages
        if len(messages) > self.limit:
            messages = messages[:self.limit]
        _logger(self.__class__).log(5, 'adding %s messages' % len(messages))
        self._finished = False
        self._new_messages = messages
        self._to_check = list(self._messages)
        self._pending_msg = messages
        # start removing messages, new message won't be added until we
        # checked all message that need to be removed
        QtCore.QTimer.singleShot(1, self._remove_batch)
242444
@Override
    public void run() {
        if (!stateUpdater.compareAndSet(this, 1, 2)) {
            return;
        }

        List<JDBCLogAttribute> messages = new ArrayList<>();
        JDBCLogAttribute msg = null;

        //only grab at most 1000 messages at a time
        for (int i = 0; i < 1000; ++i) {
            msg = pendingMessages.poll();
            if (msg == null) {
                break;
            }
            messages.add(msg);
        }
        try {
            if (!messages.isEmpty()) {
                writeMessage(messages);
            }
        } finally {
            Executor executor = this.executor;
            stateUpdater.set(this, 0);
            //check to see if there is still more messages
            //if so then run this again
            if (!pendingMessages.isEmpty()) {
                if (stateUpdater.compareAndSet(this, 0, 1)) {
                    executor.execute(this);
                }
            }
        }
    }
1245205
async def message_throttled(self, message: types.Message, throttled: Throttled):
        
        handler = current_handler.get()
        dispatcher = Dispatcher.get_current()
        if handler:
            key = getattr(handler, 'throttling_key', f"{self.prefix}_{handler.__name__}")
        else:
            key = f"{self.prefix}_message"

        # Calculate how many time is left till the block ends
        delta = throttled.rate - throttled.delta

        # Prevent flooding
        if throttled.exceeded_count <= 2:
            await message.reply('Too many requests! ')

        # Sleep.
        await asyncio.sleep(delta)

        # Check lock status
        thr = await dispatcher.check_key(key)

        # If current message is not last with current key - do not send message
        if thr.exceeded_count == throttled.exceeded_count:
            await message.reply('Unlocked.')
1249753
def _update_message_request(self, message):
        
        for each in self.row_keys:
            message.rows.row_keys.append(_to_bytes(each))

        for each in self.row_ranges:
            r_kwrags = each.get_range_kwargs()
            message.rows.row_ranges.add(**r_kwrags)
263962
def load_earlier_messages_till(self, last):
        
        timestamp = time.mktime(last.timetuple())
        self.driver.wapi_functions.loadEarlierMessagesTillDate(self.id, timestamp)
46965
def _do_pending_writes(self):
        """"""
        for text, wrap in self._pending_writes:
            # truncate in case of *really* long messages
            text = text[-self._n_cols*self._n_rows:]
            text = text.split('\n')
            text = [t if len(t) > 0 else '' for t in text]
            nr, nc = self._n_rows, self._n_cols
            for para in text:
                para = para[:nc] if not wrap else para
                lines = [para[ii:(ii+nc)] for ii in range(0, len(para), nc)]
                lines = [''] if len(lines) == 0 else lines
                for line in lines:
                    # Update row and scroll if necessary
                    self._text_lines.insert(0, line)
                    self._text_lines = self._text_lines[:nr]
                    self._bytes_012[1:] = self._bytes_012[:-1]
                    self._bytes_345[1:] = self._bytes_345[:-1]
                    self._insert_text_buf(line, 0)
        self._pending_writes = []
528923
def _load_initial_message(self, message=None):
        ''''''
        if message is None:
            message = Message(verify=False)
        if isinstance(message, Mapping):
            message = Message.load_message(message)
        self.message = message
1207259
private void fetchIfNeeded(long remainingBytes)
  {
    if ((fetchFutures.isEmpty() || fetchFutures.peekLast().isDone())
        && remainingBytes <= prefetchConfig.getPrefetchTriggerBytes()) {
      Future<Void> fetchFuture = fetchExecutor.submit(() -> {
        fetch();
        return null;
      });
      fetchFutures.add(fetchFuture);
    }
  }
1284155
async def _retrieve_messages_before_strategy(self, retrieve):
        """"""
        before = self.before.id if self.before else None
        data = await self.logs_from(self.channel.id, retrieve, before=before)
        if len(data):
            if self.limit is not None:
                self.limit -= retrieve
            self.before = Object(id=int(data[-1]['id']))
        return data