Give this Message a chance to read. The selector loop should have
received a read event for this Message.

@return true if the connection should live on, false if it should be
closed
544776
public boolean read()
    {
        if (state == State.READING_FRAME_SIZE)
        {
            // try to read the frame size completely
            if (!internalRead(frameSizeBuffer))
                return false;

            // if the frame size has been read completely, then prepare to read the
            // actual frame.
            if (frameSizeBuffer.remaining() == 0)
            {
                // pull out the frame size as an integer.
                int frameSize = frameSizeBuffer.getInt(0);

                if (frameSize <= 0)
                {
                    logger.error("Read an invalid frame size of " + frameSize + ". Are you using TFramedTransport on the client side?");
                    return false;
                }

                if (frameSize > thriftFactories.maxFrameSizeInBytes)
                {
                    logger.error("Invalid frame size got (" + frameSize + "), maximum expected " + thriftFactories.maxFrameSizeInBytes);
                    return false;
                }


                // reallocate to match frame size (if needed)
                reallocateDataBuffer(frameSize);

                frameSizeBuffer.clear(); // prepare it to the next round of reading (if any)

                state = State.READING_FRAME;
            }
            else
            {
                // this skips the check of READING_FRAME state below, since we can't
                // possibly go on to that state if there's data left to be read at
                // this one.
                state = State.READY_TO_READ_FRAME_SIZE;
                return true;
            }
        }

        // it is possible to fall through from the READING_FRAME_SIZE section
        // to READING_FRAME if there's already some frame data available once
        // READING_FRAME_SIZE is complete.

        if (state == State.READING_FRAME)
        {
            if (!internalRead(dataBuffer))
                return false;

            state = (dataBuffer.remaining() == 0)
                     ? State.READ_FRAME_COMPLETE
                     : State.READY_TO_READ_FRAME;

            // Do not read until we finish processing request.
            if (state == State.READ_FRAME_COMPLETE)
            {
                switchMode(State.READ_FRAME_COMPLETE);
            }

            return true;
        }

        // if we fall through to this point, then the state must be invalid.
        logger.error("Read was called but state is invalid (" + state + ")");
        return false;
    }
1176262
final boolean abort() {
        if (!taken.get()) {
            // aborting always runs before connection
            // happens. If we reach this point the request
            // can be active or suspended
            // but nor delivered or committed
            result = BaasResult.cancel();
            // we can simply forcefully set the value
            // to ABORTED to let the resource been cleaned up
            suspendableHandler.set(Signal.ABORTED);
            finish();
            return true;
        }
        return false;
    }
977557
@Override
	public boolean hasNext() {
		if (next == null) {
			try {
				next = readNextFromStream();
			} catch (Exception e) {
				throw new RuntimeException("Failed to receive next element: " + e.getMessage(), e);
			}
		}

		return next != null;
	}
1201465
public boolean hasNext() {
        // check if we already fetched next item
        if (next != null) {
            return true;
        }

        // check if result set already finished
        if (resultSetFinished) {
            return false;
        }

        // now fetch next item
        next = safeReadNext();

        // check if we got something
        if (next != null) {
            return true;
        }

        // no more items
        resultSetFinished = true;

        return false;
    }
1164919
public Message<?> receive(MessageSelector selector, long timeout) {
        long timeLeft = timeout;
        Message<?> message = receive(selector);

        while (message == null && timeLeft > 0) {
            timeLeft -= pollingInterval;
            
            if (RETRY_LOG.isDebugEnabled()) {
                RETRY_LOG.debug("No message received with message selector - retrying in " + (timeLeft > 0 ? pollingInterval : pollingInterval + timeLeft) + "ms");
            }
            
            try {
                Thread.sleep(timeLeft > 0 ? pollingInterval : pollingInterval + timeLeft);
            } catch (InterruptedException e) {
                RETRY_LOG.warn("Thread interrupted while waiting for retry", e);
            }
            
            message = receive(selector);
        }
        
        return message;
    }
250709
def _can_read(self):
        
        if self.__sock is None:
            return None
        if select.select([self.__sock], [], [], self.__timeout)[0]:
            return True
        else:
            self.__last_error = const.MB_TIMEOUT_ERR
            self.__debug_msg('timeout error')
            self.close()
            return None
67549
protected boolean readPacket ()
        throws IOException
    {
        int result;
        while ((result = _stream.packetout(_packet)) != 1) {
            if (result == 0 && !readPage()) {
                return false;
            }
        }
        return true;
    }
183806
public boolean checkResponseForException() {
    if (!finished && rsp != null) {
      Exception e;
      if ((e = rsp.getException()) != null) {
        setError(e.getMessage());
        setFinished();
        return true;
      }
    }
    return false;
  }
426728
public boolean limit() {

        //get connection
        Object connection = getConnection();

        Object result = limitRequest(connection);

        if (FAIL_CODE != (Long) result) {
            return true;
        } else {
            return false;
        }
    }
312249
@Override
	public boolean hasNext() {

		// iterate over input data until an element is created
		while (reader.hasNext() && nextElement == null) {

			try {
				final XMLEvent event = reader.nextEvent();

				switch (event.getEventType()) {

					case XMLEvent.START_DOCUMENT:
						startDocument();
						break;

					case XMLEvent.START_ELEMENT:
						startElement(event.asStartElement());
						break;

					case XMLEvent.END_DOCUMENT:
						endDocument();
						break;

					case XMLEvent.END_ELEMENT:
						endElement(event.asEndElement());
						break;

					case XMLEvent.CHARACTERS:
					case XMLEvent.CDATA:
						characters(event.asCharacters());
						break;

				}

			} catch (XMLStreamException strex) {
				logger.warn(strex.getMessage());
				break;
			}
		}

		// either an element has been created, or the stream is at its end
		return nextElement != null;
	}
124825
private boolean readNextRow() {
        while (!stop) {
            String row = getLineWrapped();
            // end of stream - null indicates end of stream before we see last_seq which shouldn't
            // be possible but we should handle it
            if (row == null || row.startsWith("{\"last_seq\":")) {
                terminate();
                return false;
            } else if (row.isEmpty()) {
                // heartbeat
                continue;
            }
            setNextRow(gson.fromJson(row, ChangesResult.Row.class));
            return true;
        }
        // we were stopped, end of changes feed
        terminate();
        return false;
    }
1171571
public boolean select() {
        boolean isSelect = false;
        try {
            WebElement webElement = element.getWebElement();
            if (SELECT.equalsIgnoreCase(webElement.getTagName())) {
                isSelect = true;
            }
        } catch (NoSuchElementException e) {
            log.info(e);
        }
        return isSelect;
    }
647606
public boolean hasNext() {
        if(_rs == null)
            return false;

        if(_primed)
            return true;

        try {
            _primed = _rs.next();
            return _primed;
        }
        catch(SQLException sql) {
            String msg = "An exception occurred reading from the Iterator.  Cause: " + sql;
            LOGGER.error(msg, sql);
            throw new IllegalStateException(msg, sql);
        }
    }
925886
public boolean startConnection()
  {
    State state = _state.get();
    
    if (state.isActive()) {
      // when active, always start a connection
      
      _connectionCount.incrementAndGet();
      
      return true;
    }
    
    long now = CurrentTime.currentTime();
    long lastFailTime = _lastFailTime;
    long recoverTimeout = _dynamicRecoverTimeout.get();
    
    if (now < lastFailTime + recoverTimeout) {
      // if the fail recover hasn't timed out, return false
      return false;
    }
    
    // when fail, only start a single connection
    int count;

    do {
      count = _connectionCount.get();
      
      if (count > 0) {
        return false;
      }
    } while (! _connectionCount.compareAndSet(count, count + 1));
    
    return true;
  }
1132754
protected boolean lookahead() {
        try {
            next = this.reader.readLine();
            if(next == null) {
                // TODO: make this close-on-exhaust optional?
                reader.close();
            }
            return (next!=null);
        } catch (IOException e) {
            logger.warning(e.toString());
            return false;
        }
    }
1371032
@Override
    public E peek() {
        E el;

        while (((el = super.peek()) == null) && !isDone()) {
            synchronized (this) {
                try {
                    wait();
                } catch (InterruptedException e) {
                    String s = "Reader has been interrupted maybe the connection is closed";
                    throw new RuntimeException(s);
                }
            }
        }

        if ((el == null) && isDone()) {
            String s = "Reader has been interrupted maybe the connection is closed";
            throw new RuntimeException(s);
        }

        return el;
    }
847965
private boolean waitForWebElementsToBeCreated(){
		final long endTime = SystemClock.uptimeMillis() + 5000;

		while(SystemClock.uptimeMillis() < endTime){

			if(isFinished){
				return true;
			}

			sleeper.sleepMini();
		}
		return false;
	}