wake the reader up before using the pipe again.
496032
@Override
    public boolean flush()
    {
        //  If there are no un-flushed items, do nothing.
        if (w == f) {
            return true;
        }

        //  Try to set 'c' to 'f'.
        if (!c.compareAndSet(w, f)) {
            //  Compare-and-swap was unsuccessful because 'c' is NULL.
            //  This means that the reader is asleep. Therefore we don't
            //  care about thread-safeness and update c in non-atomic
            //  manner. We'll return false to let the caller know
            //  that reader is sleeping.
            c.set(f);
            w = f;
            return false;
        }

        //  Reader is alive. Nothing special to do now. Just move
        //  the 'first un-flushed item' pointer to 'f'.
        w = f;
        return true;
    }
201398
def start_output (self):
        """"""
        super(TextLogger, self).start_output()
        if self.has_part('intro'):
            self.write_intro()
        self.flush()
347703
public function onRead()
    {
        $seq = ["\xff\xf4\xff\xfd\x06", "\xff\xec", "\x03", "\x04"];
        $finish = false;
        foreach ($seq as $s) {
            if ($this->search($s) !== false) {
                $finish = true;
            }
        }
        while (($line = $this->readline()) !== null) {
            $line = rtrim($line, "\r\n");
            $e = explode(' ', $line, 2);
            $cmd = trim(strtolower($e[0]));
            $arg = isset($e[1]) ? $e[1] : '';

            if ($cmd === 'quit' || $cmd === 'exit') {
                $this->disconnect();
            } elseif (!$this->auth) {
                $this->checkPassword($line);
            } else {
                $this->processCommand($cmd, $arg);
            }
        }

        if ($finish) {
            $this->finish();
        }
    }
171889
def resume_writing(self):
        ''''''
        if not self._can_send.is_set():
            self._can_send.set()
            self.transport.resume_reading()
848552
def resume(self):
        """"""
        directive = self._play_directive('REPLACE_ALL')
        directive['audioItem'] = self._audio_item()
        self._response['directives'].append(directive)
        return self
1213597
function pump(reader, handler) {
	reader.read().then(result => {
		if (result.done) {
			return;
		}
		if (handler(result.value) === false) {
			// cancelling
			return;
		}
		pump(reader, handler);
	});
}
96944
def _wait_event(self, reading):
        ""
        with self._registered(reading, not reading):
            (self._readable if reading else self._writable).wait()

        if scheduler.state.interrupted:
            raise IOError(errno.EINTR, "interrupted system call")
298772
function emitLine() {	
			if(lineQueue.size() > 0)
			{				
				pause();

				sink({line: lineQueue.deq(), resume});
			}
			else if(streamEnd) {
				sink(new Bacon.End());
			}
			else {
				//If we've run out of lines to emit
				readStream.resume();
			}
		}
517545
def cleanup(self):
        '''  '''
        self._processing_stop = True
        self._wakeup_processing_thread()
        self._processing_stopped_event.wait(3)
214024
def _wake(self):
        
        try:
            self.transmit_side.write(b(' '))
        except OSError:
            e = sys.exc_info()[1]
            if e.args[0] != errno.EBADF:
                raise
666161
def sleep(self, time):
        
        target = 'wait for %s' % str(time)
        self.device(text=target).wait.exists(timeout=time)
1315615
public function onRead()
    {
        packet:
        if ($this->state === self::STATE_STANDBY) {
            if ($this->bev->input->length < 4) {
                return;
            }
            $this->pctSize = Binary::bytes2int($this->read(3), true);
            $this->setWatermark($this->pctSize, $this->pctSize);
            $this->state = self::STATE_BODY;
            $this->seq = ord($this->read(1)) + 1;
        }
        /* STATE_BODY */
        $l = $this->bev->input->length;
        if ($l < $this->pctSize) {
            return;
        }
        $this->state = self::STATE_STANDBY;
        $this->setWatermark(4);
        if ($this->phase === 0) {
            $this->phase = self::PHASE_GOT_INIT;
            $this->protover = ord($this->read(1));
            if ($this->protover === 0xFF) { // error
                $fieldCount = $this->protover;
                $this->protover = 0;
                $this->onResponse->push(function ($conn, $result) {
                    if ($conn->onConnected) {
                        $conn->connected = true;
                        $conn->onConnected->executeAll($conn, $result);
                        $conn->onConnected = null;
                    }
                });
                goto field;
            }
            if (($p = $this->search("\x00")) === false) {
                $this->log('nul-terminator of \'serverver\' is not found');
                $this->finish();
                return;
            }
            $this->serverver = $this->read($p);
            $this->drain(1); // drain nul-byte
            $this->threadId = Binary::bytes2int($this->read(4), true);
            $this->scramble = $this->read(8);
            $this->drain(1); // ????

            $this->serverCaps = Binary::bytes2int($this->read(2), true);
            $this->serverLang = ord($this->read(1));
            $this->serverStatus = Binary::bytes2int($this->read(2), true);
            $this->drain(13);
            $restScramble = $this->read(12);
            $this->scramble .= $restScramble;
            $this->drain(1);

            $this->auth();
        } else {
            $fieldCount = ord($this->read(1));
            field:
            if ($fieldCount === 0xFF) {
                // Error packet
                $u = unpack('v', $this->read(2));
                $this->errno = $u[1];
                $state = $this->read(6);
                $this->errmsg = $this->read($this->pctSize - $l + $this->bev->input->length);
                $this->onError();
                $this->errno = 0;
                $this->errmsg = '';
            } elseif ($fieldCount === 0x00) {
                // OK Packet Empty
                if ($this->phase === self::PHASE_AUTH_SENT) {
                    $this->phase = self::PHASE_HANDSHAKED;

                    if ($this->dbname !== '') {
                        $this->query('USE `' . $this->dbname . '`');
                    }
                }

                $this->affectedRows = $this->parseEncodedBinary();

                $this->insertId = $this->parseEncodedBinary();

                $u = unpack('v', $this->read(2));
                $this->serverStatus = $u[1];

                $u = unpack('v', $this->read(2));
                $this->warnCount = $u[1];

                $this->message = $this->read($this->pctSize - $l + $this->bev->input->length);
                $this->onResultDone();
            } elseif ($fieldCount === 0xFE) {
                // EOF Packet
                if ($this->rsState === self::RS_STATE_ROW) {
                    $this->onResultDone();
                } else {
                    ++$this->rsState;
                }
            } else {
                // Data packet
                $this->prependInput(chr($fieldCount));

                if ($this->rsState === self::RS_STATE_HEADER) {
                    // Result Set Header Packet
                    $extra = $this->parseEncodedBinary();
                    $this->rsState = self::RS_STATE_FIELD;
                } elseif ($this->rsState === self::RS_STATE_FIELD) {
                    // Field Packet
                    $field = [
                        'catalog' => $this->parseEncodedString(),
                        'db' => $this->parseEncodedString(),
                        'table' => $this->parseEncodedString(),
                        'org_table' => $this->parseEncodedString(),
                        'name' => $this->parseEncodedString(),
                        'org_name' => $this->parseEncodedString()
                    ];

                    $this->drain(1); // filler

                    $u = unpack('v', $this->read(2));

                    $field['charset'] = $u[1];
                    $u = unpack('V', $this->read(4));
                    $field['length'] = $u[1];

                    $field['type'] = ord($this->read(1));

                    $u = unpack('v', $this->read(2));
                    $field['flags'] = $u[1];

                    $field['decimals'] = ord($this->read(1));

                    $this->resultFields[] = $field;
                } elseif ($this->rsState === self::RS_STATE_ROW) {
                    // Row Packet
                    $row = [];

                    for ($i = 0, $nf = sizeof($this->resultFields); $i < $nf; ++$i) {
                        $row[$this->resultFields[$i]['name']] = $this->parseEncodedString();
                    }

                    $this->resultRows[] = $row;
                }
            }
        }
        if ($this->finished) {
            return;
        }
        $this->drain($this->pctSize - $l + $this->bev->input->length); // drain the rest of packet
        goto packet;
    }
1054779
def wake(self):
        
        configuration = self._read_configuration()
        self._configuration_register(configuration | 0x0007)
        # 40us delay to recover from powerdown (p14 of spec)
        time.sleep(0.00004)
916250
public void pleaseStop()
    {
    	if (stopRequired)
    		return;
    	
        stopRequired = true;
        try
        {
            if (receiver != null)
                receiver.close();
        }
        catch (JMSException e)
        {
        	ErrorTools.log(e, log);
        }
    }
540595
def wakeup
      raise NotRunning.new unless running?
      if(@sleeper.waiters > 0)
        @sleeper.signal
      else
        @timer_thread.wakeup if @timer_thread.alive? && @timer_thread.stop?
      end
    end
1248876
private void scheduleReadTimeout() {
		if (scheduledReadTimeout == null) {
			scheduledReadTimeout = eventloop.delayBackground(readTimeout, () -> {
				if (inspector != null) inspector.onReadTimeout();
				scheduledReadTimeout = null;
				close(TIMEOUT_EXCEPTION);
			});
		}
	}
964060
def _wake_up_first(self):
        """"""
        for fut in self._waiters:
            if not fut.done():
                fut.set_result(True)
                break