1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 17:52:14 +01:00
parallel/test/Threading/ThreadTest.php
Aaron Piotrowski da84a772cf Port to Amp
2016-08-18 11:04:48 -05:00

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();
}
}