public function wait($timeout = null, $step = 1000)
    {
        $withTimeout = false === is_null($timeout);

        if ($withTimeout) {
            $start = microtime(true);
            if ($timeout < $step) {
                $step = $timeout;
            }
        }

        while ($this->isRunning()) {
            usleep($step * 1000);

            if ($withTimeout && ($start + $timeout) > microtime(true)) {
                return;
            }
        }
    }