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:
parent
ba3ac988b3
commit
72fc493fe9
@ -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);
|
||||||
|
|
||||||
|
@ -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()));
|
||||||
|
@ -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.
|
Loading…
Reference in New Issue
Block a user