1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-12 09:09:35 +01:00
parallel/test/Threading/ThreadTest.php
2017-01-09 11:11:25 -06:00

29 lines
609 B
PHP

<?php
namespace Amp\Parallel\Test\Threading;
use Amp\Parallel\Threading\Thread;
use Amp\Parallel\Test\AbstractContextTest;
use AsyncInterop\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();
}));
}
}