Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/EventLoop/Driver/UvDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct()
$this->handle = \uv_loop_new();

$this->ioCallback = function ($event, $status, $events, $resource): void {
$callbacks = $this->uvCallbacks[(int) $event];
$callbacks = $this->uvCallbacks[spl_object_id($event)];

// Invoke the callback on errors, as this matches behavior with other loop back-ends.
// Re-enable callback as libuv disables the callback on non-zero status.
Expand Down Expand Up @@ -66,15 +66,15 @@ public function __construct()
};

$this->timerCallback = function ($event): void {
$callback = $this->uvCallbacks[(int) $event][0];
$callback = $this->uvCallbacks[spl_object_id($event)][0];

\assert($callback instanceof TimerCallback);

$this->enqueueCallback($callback);
};

$this->signalCallback = function ($event): void {
$callback = $this->uvCallbacks[(int) $event][0];
$callback = $this->uvCallbacks[spl_object_id($event)][0];

$this->enqueueCallback($callback);
};
Expand All @@ -92,7 +92,7 @@ public function cancel(string $callbackId): void
}

$event = $this->events[$callbackId];
$eventId = (int) $event;
$eventId = spl_object_id($event);

if (isset($this->uvCallbacks[$eventId][0])) { // All except IO callbacks.
unset($this->uvCallbacks[$eventId]);
Expand Down Expand Up @@ -159,7 +159,7 @@ protected function activate(array $callbacks): void
$event = $this->streams[$streamId] = \uv_poll_init_socket($this->handle, $callback->stream);
}

$eventId = (int) $event;
$eventId = spl_object_id($event);
$this->events[$id] = $event;
$this->uvCallbacks[$eventId][$id] = $callback;

Expand All @@ -177,7 +177,7 @@ protected function activate(array $callbacks): void
$event = $this->events[$id] = \uv_timer_init($this->handle);
}

$this->uvCallbacks[(int) $event] = [$callback];
$this->uvCallbacks[spl_object_id($event)] = [$callback];

\uv_timer_start(
$event,
Expand All @@ -193,7 +193,7 @@ protected function activate(array $callbacks): void
$event = $this->events[$id] = \uv_signal_init($this->handle);
}

$this->uvCallbacks[(int) $event] = [$callback];
$this->uvCallbacks[spl_object_id($event)] = [$callback];

/** @psalm-suppress TooManyArguments */
\uv_signal_start($event, $this->signalCallback, $callback->signal);
Expand Down Expand Up @@ -224,7 +224,7 @@ protected function deactivate(DriverCallback $callback): void

if ($callback instanceof StreamCallback) {
$flags = 0;
foreach ($this->uvCallbacks[(int) $event] as $w) {
foreach ($this->uvCallbacks[spl_object_id($event)] as $w) {
\assert($w instanceof StreamCallback);

$flags |= $w->invokable ? ($this->getStreamCallbackFlags($w)) : 0;
Expand Down