2016-08-22 06:40:48 +02:00
|
|
|
<?php declare(strict_types = 1);
|
2015-09-26 06:41:15 +02:00
|
|
|
|
2016-08-19 00:36:58 +02:00
|
|
|
namespace Amp\Concurrent\Test\Forking;
|
2016-08-18 18:04:48 +02:00
|
|
|
|
|
|
|
use Amp\Concurrent\Forking\Fork;
|
2016-08-19 00:36:58 +02:00
|
|
|
use Amp\Concurrent\Test\AbstractContextTest;
|
2015-09-26 06:41:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group forking
|
|
|
|
* @requires extension pcntl
|
|
|
|
*/
|
2016-08-19 00:36:58 +02:00
|
|
|
class ForkTest extends AbstractContextTest {
|
|
|
|
public function createContext(callable $function) {
|
2015-09-26 06:41:15 +02:00
|
|
|
return new Fork($function);
|
|
|
|
}
|
|
|
|
|
2016-08-19 00:36:58 +02:00
|
|
|
public function testSpawnStartsFork() {
|
|
|
|
\Amp\execute(function () {
|
2015-09-26 06:41:15 +02:00
|
|
|
$fork = Fork::spawn(function () {
|
|
|
|
usleep(100);
|
|
|
|
});
|
|
|
|
|
2016-08-19 00:36:58 +02:00
|
|
|
return yield $fork->join();
|
|
|
|
});
|
2015-09-26 06:41:15 +02:00
|
|
|
}
|
|
|
|
}
|