2015-09-26 06:41:15 +02:00
|
|
|
<?php
|
|
|
|
namespace Icicle\Tests\Concurrent\Forking;
|
|
|
|
|
|
|
|
use Icicle\Concurrent\Forking\Fork;
|
|
|
|
use Icicle\Coroutine;
|
|
|
|
use Icicle\Loop;
|
|
|
|
use Icicle\Tests\Concurrent\AbstractContextTest;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group forking
|
|
|
|
* @requires extension pcntl
|
|
|
|
*/
|
|
|
|
class ForkTest extends AbstractContextTest
|
|
|
|
{
|
|
|
|
public function createContext(callable $function)
|
|
|
|
{
|
|
|
|
return new Fork($function);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSpawnStartsFork()
|
|
|
|
{
|
|
|
|
Coroutine\create(function () {
|
|
|
|
$fork = Fork::spawn(function () {
|
|
|
|
usleep(100);
|
|
|
|
});
|
|
|
|
|
2016-01-23 07:00:56 +01:00
|
|
|
return yield from $fork->join();
|
2015-09-26 06:41:15 +02:00
|
|
|
})->done();
|
|
|
|
|
|
|
|
Loop\run();
|
|
|
|
}
|
|
|
|
}
|