Skip to content

Commit

Permalink
fix(channel): return immediately after cancelling send/recieve callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
azjezz committed Nov 23, 2021
1 parent 23a5a61 commit ced10a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Psl/Channel/Internal/Receiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function receive(): mixed
Async\Scheduler::repeat(0.0001, function (string $identifier): void {
if (null === $this->deferred) {
Async\Scheduler::cancel($identifier);

return;
}

if ($this->state->isClosed()) {
Expand Down
2 changes: 2 additions & 0 deletions src/Psl/Channel/Internal/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function send(mixed $message): void
Async\Scheduler::repeat(0.0001, function (string $identifier): void {
if (null === $this->deferred) {
Async\Scheduler::cancel($identifier);

return;
}

if ($this->state->isClosed()) {
Expand Down

0 comments on commit ced10a2

Please sign in to comment.