-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support coroutine switch in autoload
- Loading branch information
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace SwowTestYieldInAutoload; | ||
|
||
class Foo | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--TEST-- | ||
swow_coroutine: | ||
--SKIPIF-- | ||
<?php | ||
require __DIR__ . '/../../include/skipif.php'; | ||
?> | ||
--FILE-- | ||
<?php | ||
require __DIR__ . '/../../include/bootstrap.php'; | ||
|
||
use Swow\Coroutine; | ||
use Swow\Sync\WaitReference; | ||
use SwowTestYieldInAutoload\Foo; | ||
|
||
$wr = new WaitReference(); | ||
|
||
spl_autoload_register(function (string $class): void { | ||
usleep(1000); // coroutine context switch | ||
require_once __DIR__ . '/foo.inc'; | ||
}); | ||
|
||
for ($i = 0; $i < 3; ++$i) { | ||
Coroutine::run(static function () use ($wr): void { | ||
var_dump(new Foo()); | ||
}); | ||
} | ||
|
||
$wr::wait($wr); | ||
|
||
?> | ||
--EXPECTF-- | ||
object(%s\Foo)#%d (0) { | ||
} | ||
object(%s\Foo)#%d (0) { | ||
} | ||
object(%s\Foo)#%d (0) { | ||
} |