1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-12 09:09:35 +01:00
parallel/test/Sync/Fixture/parcel.php
2019-08-27 12:17:41 -05:00

20 lines
407 B
PHP

<?php
namespace Amp\Parallel\Test\Sync\Fixture;
use Amp\Parallel\Sync\SharedMemoryParcel;
return function () use ($argv): \Generator {
if (!isset($argv[1])) {
throw new \Error('No parcel ID given');
}
$parcel = SharedMemoryParcel::use($argv[1]);
yield $parcel->synchronized(function (int $value): int {
return $value + 1;
});
return yield $parcel->unwrap();
};