1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 17:52:14 +01:00
parallel/test/Threading/ThreadTest.php
2016-12-29 19:20:19 -06:00

29 lines
610 B
PHP

<?php
namespace Amp\Parallel\Test\Threading;
use Amp\Parallel\Threading\Thread;
use Amp\Parallel\Test\AbstractContextTest;
use Interop\Async\Loop;
/**
* @group threading
* @requires extension pthreads
*/
class ThreadTest extends AbstractContextTest {
public function createContext(callable $function) {
return new Thread($function);
}
public function testSpawnStartsThread() {
Loop::execute(\Amp\wrap(function () {
$thread = Thread::spawn(function () {
usleep(100);
});
return yield $thread->join();
}));
}
}