depth; } public function resume(): void { $this->depth = max( 0, $this->depth - 1 ); } public function is_paused(): bool { return $this->depth > 0; } /** * Run a callback with sync paused. * * @template T * @param callable(): T $callback * @return T */ public function paused( callable $callback ): mixed { $this->pause(); try { return $callback(); } finally { $this->resume(); } } }