1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-03 18:17:52 +01:00
parallel/test/Threading/ThreadTest.php

34 lines
660 B
PHP
Raw Normal View History

2015-08-28 23:58:15 +02:00
<?php
2016-08-18 18:04:48 +02:00
namespace Amp\Tests\Concurrent\Threading;
use Amp\Concurrent\Threading\Thread;
use Amp\Coroutine;
use Amp\Loop;
use Amp\Tests\Concurrent\AbstractContextTest;
2015-08-28 23:58:15 +02:00
/**
* @group threading
* @requires extension pthreads
*/
class ThreadTest extends AbstractContextTest
2015-08-28 23:58:15 +02:00
{
public function createContext(callable $function)
2015-09-02 23:34:42 +02:00
{
return new Thread($function);
}
public function testSpawnStartsThread()
{
Coroutine\create(function () {
$thread = Thread::spawn(function () {
usleep(100);
});
2016-01-23 07:00:56 +01:00
return yield from $thread->join();
})->done();
Loop\run();
}
2015-08-28 23:58:15 +02:00
}