mirror of
https://github.com/danog/parallel.git
synced 2024-12-02 17:52:14 +01:00
34 lines
660 B
PHP
34 lines
660 B
PHP
<?php
|
|
|
|
namespace Amp\Tests\Concurrent\Threading;
|
|
|
|
use Amp\Concurrent\Threading\Thread;
|
|
use Amp\Coroutine;
|
|
use Amp\Loop;
|
|
use Amp\Tests\Concurrent\AbstractContextTest;
|
|
|
|
/**
|
|
* @group threading
|
|
* @requires extension pthreads
|
|
*/
|
|
class ThreadTest extends AbstractContextTest
|
|
{
|
|
public function createContext(callable $function)
|
|
{
|
|
return new Thread($function);
|
|
}
|
|
|
|
public function testSpawnStartsThread()
|
|
{
|
|
Coroutine\create(function () {
|
|
$thread = Thread::spawn(function () {
|
|
usleep(100);
|
|
});
|
|
|
|
return yield from $thread->join();
|
|
})->done();
|
|
|
|
Loop\run();
|
|
}
|
|
}
|