PHPDaemon\Thread\IPC::shutdown PHP Method

shutdown() public method

Shutdown thread
public shutdown ( $hard = false ) : boolean | null
return boolean | null - Ready?
    public function shutdown($hard = false)
    {
        $error = error_get_last();
        if ($error) {
            if ($error['type'] === E_ERROR) {
                $this->log('crashed by error \'' . $error['message'] . '\' at ' . $error['file'] . ':' . $error['line']);
            }
        }
        if (Daemon::$config->throwexceptiononshutdown->value) {
            throw new \Exception('event shutdown');
        }
        @ob_flush();
        if ($this->terminated === true) {
            if ($hard) {
                exit(0);
            }
            return;
        }
        $this->terminated = true;
        if ($hard) {
            exit(0);
        }
        FileSystem::waitAllEvents();
        // ensure that all I/O events completed before suicide
        posix_kill(posix_getppid(), SIGCHLD);
        // praying to Master
        exit(0);
        // R.I.P.
    }