*/ private array $cancellations = []; private string $nextId = "a"; /** @var array */ private array $callbacks = []; private ?CancelledException $exception = null; public function __construct(Cancellation ...$cancellations) { $thatException = &$this->exception; $thatCallbacks = &$this->callbacks; $thatCancellations = &$this->cancellations; $onCancel = static function (CancelledException $exception) use ( &$thatException, &$thatCallbacks, &$thatCancellations, ): void { if ($thatException) { return; } $thatException = $exception; foreach ($thatCancellations as [$cancellation, $id]) { /** @var Cancellation $cancellation */ $cancellation->unsubscribe($id); } $thatCancellations = []; foreach ($thatCallbacks as $callback) { EventLoop::queue($callback, $exception); } $thatCallbacks = []; }; foreach ($cancellations as $cancellation) { $id = $cancellation->subscribe($onCancel); $this->cancellations[] = [$cancellation, $id]; } } public function __destruct() { foreach ($this->cancellations as [$cancellation, $id]) { /** @var Cancellation $cancellation */ $cancellation->unsubscribe($id); } // The reference created in the constructor causes this property to persist beyond the life of this object, // so explicitly removing references will speed up garbage collection. $this->cancellations = []; } public function subscribe(\Closure $callback): string { $id = $this->nextId++; if ($this->exception) { EventLoop::queue($callback, $this->exception); } else { $this->callbacks[$id] = $callback; } return $id; } public function unsubscribe(string $id): void { unset($this->callbacks[$id]); } public function isRequested(): bool { return $this->exception !== null; } public function throwIfRequested(): void { if ($this->exception) { throw $this->exception; } } } __halt_compiler();----SIGNATURE:----v49eNc9R16figXF7wY2ziNSbJFAxru1iDUZXzK+Qc3M9jCcR1Yb5j1JVeo17PGnTLTBjXL6JuP5CeG5kM4xIBnHHU+DuukZBpcRb9n/pph6/t6c4qkPEsL7PBwmMOZNBlET8nLsUCVv3/P7THlsOzasEAnKsYiq9jrWxsULjMzVXoij40rOW3aK2q67cIl+94AdrhVRnEttwqodb2Hq2z2O3INQHEALyPchGiTK1ChodkrTNMN/719r8B+rrYsLXV/NKZTTSIpeYz+k97CYxS6sGtSZC/5vBNSNpLQ3WB/JAor0Nt3/w82KiYBFyej3c4UDdJdd1HkFz1HchD3cszG4PcAlHhm/jp+Qooezghcd7uVPHhyjDUx/D81OVCmNn97BByDm28tIYhTTN+/XH21b0xLsMz4LrsUwaEBviFsFqXTnJk9zfY+X2Qky05X0hkChn7BFRY2abpoI3Dm9fuEL3942rl0Webk6VzZkOpp8G2kaFylhz2Qrx5ozRa1C0SPv7207AtM+law2IWxqeZt0tmqzr+pmkU9Gh2CntE+r78yR6KEXck7PiDI+zY45u60c60UM0quYwOhKVkrCOiLPZEm9kFw9YZiTt+A+1kZvWJAFFa43qNSDCH+hOEsToEaOkZJfQmU7euH3PAuyv5wvWvm4p13Sd/FogOiNpcn4=----ATTACHMENT:----MTgwMDU5MzA0NDI2NzU0MyA0NTUwNjE0MDAwMjU3NTg4IDEzMTQ0MDU3NzM5OTgwODY=