Skip to content

Commit 903edcb

Browse files
authored
Remove Revolt\launch (#6)
As all event callbacks and queue automatically create a new fiber upon suspension, there's no need for a separate function anymore. EventLoop::queue can be used as direct replacement without the need to even create a new fiber if there's no suspension happening.
1 parent c53fabf commit 903edcb

3 files changed

Lines changed: 3 additions & 26 deletions

File tree

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
"Revolt\\": "src"
4343
},
4444
"files": [
45-
"src/functions.php",
46-
"src/EventLoop/Internal/functions.php"
45+
"src/functions.php"
4746
]
4847
},
4948
"autoload-dev": {

src/EventLoop/Internal/functions.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/EventLoopTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PHPUnit\Framework\TestCase;
66
use Revolt\EventLoop;
7-
use function Revolt\launch;
87

98
class EventLoopTest extends TestCase
109
{
@@ -106,7 +105,7 @@ public function testFiberReuse(): void
106105

107106
public function testRunInFiber(): void
108107
{
109-
launch(fn () => EventLoop::run());
108+
EventLoop::queue(fn () => EventLoop::run());
110109

111110
$this->expectException(\Error::class);
112111
$this->expectExceptionMessage("within a fiber");
@@ -154,7 +153,7 @@ public function testSuspensionWithinFiber(): void
154153
{
155154
$invoked = false;
156155

157-
launch(function () use (&$invoked): void {
156+
EventLoop::queue(function () use (&$invoked): void {
158157
$suspension = EventLoop::createSuspension();
159158

160159
EventLoop::defer(fn () => $suspension->resume('test'));

0 commit comments

Comments
 (0)