1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 09:37:57 +01:00
parallel/examples/blocking-process.php

21 lines
579 B
PHP
Raw Normal View History

<?php
// The function returned by this script is run by process.php in a separate process.
// $argc and $argv are available in this process as any other cli PHP script.
use Amp\Parallel\Sync\Channel;
return function (Channel $channel): \Generator {
2018-10-07 16:50:45 +02:00
\printf("Received the following from parent: %s\n", yield $channel->receive());
print "Sleeping for 3 seconds...\n";
2018-10-07 16:50:45 +02:00
\sleep(3); // Blocking call in process.
yield $channel->send("Data sent from child.");
print "Sleeping for 2 seconds...\n";
2018-10-07 16:50:45 +02:00
\sleep(2); // Blocking call in process.
return 42;
};