1
0
mirror of https://github.com/danog/parallel.git synced 2025-01-05 20:28:18 +01:00
parallel/test/Sync/Fixture/parcel.php

20 lines
407 B
PHP
Raw Normal View History

2019-08-27 19:17:41 +02:00
<?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();
};