mirror of
https://github.com/danog/parallel.git
synced 2024-11-26 20:34:40 +01:00
Better name for forked processes
This commit is contained in:
parent
ba3ac988b3
commit
72fc493fe9
@ -2,12 +2,12 @@
|
||||
<?php
|
||||
require dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
||||
use Icicle\Concurrent\Forking\Process;
|
||||
use Icicle\Concurrent\Forking\Fork;
|
||||
use Icicle\Coroutine;
|
||||
use Icicle\Loop;
|
||||
|
||||
Coroutine\create(function () {
|
||||
$context = Process::spawn(function () {
|
||||
$context = Fork::spawn(function () {
|
||||
print "Child sleeping for 4 seconds...\n";
|
||||
sleep(4);
|
||||
|
||||
|
@ -13,8 +13,10 @@ $timer = Loop\periodic(1, function () {
|
||||
});
|
||||
|
||||
Coroutine\create(function () {
|
||||
$foo = 1;
|
||||
|
||||
// Create a new child thread that does some blocking stuff.
|
||||
$context = Thread::spawn(function () {
|
||||
$context = Thread::spawn(function () use ($foo) {
|
||||
printf("\$this: %s\n", get_class($this));
|
||||
|
||||
printf("Received the following from parent: %s\n", (yield $this->receive()));
|
||||
|
@ -16,7 +16,7 @@ use Icicle\Loop;
|
||||
/**
|
||||
* Implements a UNIX-compatible context using forked processes.
|
||||
*/
|
||||
class Process implements ContextChannelInterface
|
||||
class Fork implements ContextChannelInterface
|
||||
{
|
||||
/**
|
||||
* @var \Icicle\Concurrent\Sync\Channel A channel for communicating with the child.
|
Loading…
Reference in New Issue
Block a user