Interop\Async\Loop::stop PHP 메소드

stop() 공개 정적인 메소드

When an event loop is stopped, it continues with its current tick and exits the loop afterwards. Multiple calls to stop MUST be ignored and MUST NOT raise an exception.
public static stop ( ) : void
리턴 void
    public static function stop()
    {
        $driver = self::$driver ?: self::get();
        $driver->stop();
    }

Usage Example

예제 #1
0
파일: worker.php 프로젝트: koolkode/async
                list($type, $payload) = (yield from $transmitter->receive());
                if ($type === SocketTransmitter::TYPE_EXIT) {
                    yield from $transmitter->send($payload, $type);
                    $socket->close();
                    $exitCode = 0;
                    break;
                }
                try {
                    if (isset($payload['func'])) {
                        if (\substr($payload['func'], 0, 1) === '@') {
                            $result = \substr($payload['func'], 1)(...$payload['args'] ?? []);
                        } else {
                            $result = $payload['func'](...$payload['args'] ?? []);
                        }
                    } elseif (isset($payload['class']) && isset($payload['method'])) {
                        $result = $payload['class']::{$payload['method']}(...$payload['args'] ?? []);
                    } else {
                        throw new \RuntimeException('No callable target passed to threaded worker');
                    }
                } catch (\Throwable $e) {
                    yield from $transmitter->sendError($e);
                    continue;
                }
                yield from $transmitter->send($result, SocketTransmitter::TYPE_DATA);
            }
        } finally {
            Loop::stop();
        }
    });
}, new NativeLoop());
exit($exitCode);
All Usage Examples Of Interop\Async\Loop::stop