public function wait($timeout = null)
    {
        $x = null;                      // trash var needed for socket_select
        $startTime = microtime(true);
        while (true) {
            $this->apply();                         // maintain worker queue

            // check each child socket pair for a new result
            $read = array_map(function($w){ return $w['socket']; }, $this->workers);
            // it's possible for no workers/sockets to be present due to REAPING
            if (!empty($read)) {
                $ok = @socket_select($read, $x, $x, $timeout);
                if ($ok !== false and $ok > 0) {
                    return $read;
                }
            }

            // timed out?
            if ($timeout and microtime(true) - $startTime > $timeout) {
                return null;
            }

            // no sense in waiting if we have no workers and no more pending
            if (empty($this->workers) and empty($this->pending)) {
                return null;
            }
        }
    }
public function wait($timeout = null)
    {
        $x = null;                      // trash var needed for socket_select
        $startTime = microtime(true);
        while (true) {
            $this->apply();                         // maintain worker queue

            // check each child socket pair for a new result
            $read = array_map(function($w){ return $w['socket']; }, $this->workers);
            // it's possible for no workers/sockets to be present due to REAPING
            if (!empty($read)) {
                $ok = @socket_select($read, $x, $x, $timeout);
                if ($ok !== false and $ok > 0) {
                    return $read;
                }
            }

            // timed out?
            if ($timeout and microtime(true) - $startTime > $timeout) {
                return null;
            }

            // no sense in waiting if we have no workers and no more pending
            if (empty($this->workers) and empty($this->pending)) {
                return null;
            }
        }
    }
public function wait ( $ timeout = null ) { $ x = null ; // trash var needed for socket_select $ startTime = microtime ( true ) ; while ( true ) { $ this -> apply ( ) ; // maintain worker queue // check each child socket pair for a new result $ read = array_map ( function ( $ w ) { return $ w [ 'socket' ] ; } , $ this -> workers ) ; // it's possible for no workers/sockets to be present due to REAPING if ( ! empty ( $ read ) ) { $ ok = @ socket_select ( $ read , $ x , $ x , $ timeout ) ; if ( $ ok !== false and $ ok > 0 ) { return $ read ; } } // timed out? if ( $ timeout and microtime ( true ) - $ startTime > $ timeout ) { return null ; } // no sense in waiting if we have no workers and no more pending if ( empty ( $ this -> workers ) and empty ( $ this -> pending ) ) { return null ; } } }
Wait for any child to be ready

@param integer $timeout Timeout to wait (fractional seconds)
@return array|null Returns array of sockets ready to be READ or null
Wait for any child to be ready