1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-30 04:39:01 +01:00

Better name for forked processes

This commit is contained in:
coderstephen 2015-08-24 11:20:22 -05:00
parent ba3ac988b3
commit 72fc493fe9
3 changed files with 6 additions and 4 deletions

View File

@ -2,12 +2,12 @@
<?php <?php
require dirname(__DIR__).'/vendor/autoload.php'; require dirname(__DIR__).'/vendor/autoload.php';
use Icicle\Concurrent\Forking\Process; use Icicle\Concurrent\Forking\Fork;
use Icicle\Coroutine; use Icicle\Coroutine;
use Icicle\Loop; use Icicle\Loop;
Coroutine\create(function () { Coroutine\create(function () {
$context = Process::spawn(function () { $context = Fork::spawn(function () {
print "Child sleeping for 4 seconds...\n"; print "Child sleeping for 4 seconds...\n";
sleep(4); sleep(4);

View File

@ -13,8 +13,10 @@ $timer = Loop\periodic(1, function () {
}); });
Coroutine\create(function () { Coroutine\create(function () {
$foo = 1;
// Create a new child thread that does some blocking stuff. // 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("\$this: %s\n", get_class($this));
printf("Received the following from parent: %s\n", (yield $this->receive())); printf("Received the following from parent: %s\n", (yield $this->receive()));

View File

@ -16,7 +16,7 @@ use Icicle\Loop;
/** /**
* Implements a UNIX-compatible context using forked processes. * 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. * @var \Icicle\Concurrent\Sync\Channel A channel for communicating with the child.