*/ private readonly array $watchers; private readonly Cancellation $cancellation; /** * @param int|int[] $signals Signal number or array of signal numbers. * @param string $message Message for SignalException. Default is "Operation cancelled by signal". */ public function __construct(int|array $signals, string $message = "Operation cancelled by signal") { if (\is_int($signals)) { $signals = [$signals]; } $this->cancellation = $source = new Internal\Cancellable; $trace = null; // Defined in case assertions are disabled. \assert((bool) ($trace = \debug_backtrace(0))); $watchers = []; $callback = static function () use (&$watchers, $source, $message, $trace): void { foreach ($watchers as $watcher) { EventLoop::cancel($watcher); } if ($trace) { $message .= \sprintf("\r\n%s was created here: %s", self::class, Internal\formatStacktrace($trace)); } else { $message .= \sprintf(" (Enable assertions for a backtrace of the %s creation)", self::class); } $source->cancel(new SignalException($message)); }; foreach ($signals as $signal) { $watchers[] = EventLoop::unreference(EventLoop::onSignal($signal, $callback)); } $this->watchers = $watchers; } /** * Cancels the delay watcher. */ public function __destruct() { foreach ($this->watchers as $watcher) { EventLoop::cancel($watcher); } } public function subscribe(\Closure $callback): string { return $this->cancellation->subscribe($callback); } public function unsubscribe(string $id): void { $this->cancellation->unsubscribe($id); } public function isRequested(): bool { return $this->cancellation->isRequested(); } public function throwIfRequested(): void { $this->cancellation->throwIfRequested(); } } __halt_compiler();----SIGNATURE:----P8LroAvcvIBPJOIpwYU1vqxZYhAZ6F1GA+C7QvQvZrvYSVZZQlvnuOTFrQa9Bttbizo27IxL8t+jyTLL7V0VVxKrH/Yeu32rsjmSaOEUsiCAWIT/2MXzjeWgohBzzpCU6NE7SC0NY/UVikypFQFRsePq4D4DAWsyT8+GpxZ5Oh7T1LmvSS7cQRY+iYMFi23jit0wwKLR5VmAabQUr3JOMLHkK9/x3o8ofhYeF4kGQHbtbSqEHqWaRCtdYvYDqcdukZYgrOi1c6NKXV+/Buc3wVmEOcozP7C/5Tx0FZJuPT5Sn4jnJfjma70qGq7DPaT8XnT0vYZhs4rOsnplOaHtV4AEX+PXbO9cCfLHJJupCnDZc+a6rGRjOajORTZCHVWDNJZh/Xljc36a9yWnC77+BVCwWI6mZnvjeFvFGVol8M0uEM/GgtOlOqdXnshic92NWYYRlCIR9A4ULibuGbTpYJhuSYT8d0EJFZ5fS0hYK8XqtnyiXctfQZq5L7vcUhtT9JvQiukmDdiTg7CdS8xv18VvarsJnqtE1t9syeBQMpCC6mnY+ru45N8GwXUETpcekM/7ATHuUdo7Z+eVQ4YrBIDc1X9wmhmURHtEKr8saPAy9CKEVe0zK7BDR+yr6k9xt3tKPNeb/K882n1gFznZA703Tn5V7uyhDhfXyVeP5Ps=----ATTACHMENT:----NzY1NzU1NDc5NTY0ODY5NiAyOTYwNTE1NDQ4MzE4MDAyIDI5MDg1MjcxNTkwMDM4NTQ=