mirror of
https://github.com/danog/parallel.git
synced 2024-12-12 09:09:35 +01:00
33 lines
662 B
PHP
33 lines
662 B
PHP
<?php
|
|
namespace Icicle\Tests\Concurrent\Threading;
|
|
|
|
use Icicle\Concurrent\Threading\Thread;
|
|
use Icicle\Coroutine;
|
|
use Icicle\Loop;
|
|
use Icicle\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);
|
|
});
|
|
|
|
yield $thread->join();
|
|
})->done();
|
|
|
|
Loop\run();
|
|
}
|
|
}
|