diff --git a/examples/blocking-process.php b/examples/blocking-process.php index 3c0d200..69596a6 100644 --- a/examples/blocking-process.php +++ b/examples/blocking-process.php @@ -1,7 +1,6 @@ getStdout(), new ByteStream\ResourceOutputStream(STDOUT))); + print "Waiting 2 seconds to send start data...\n"; yield new Delayed(2000); diff --git a/examples/shared-memory-parcel.php b/examples/shared-memory-parcel.php index 129276d..96e7bc4 100755 --- a/examples/shared-memory-parcel.php +++ b/examples/shared-memory-parcel.php @@ -2,6 +2,7 @@ getStdout(), new ByteStream\ResourceOutputStream(STDOUT))); + yield new Delayed(100); // Give the process time to start and access the parcel. yield $parcel->synchronized(function (int $value) { diff --git a/examples/thread.php b/examples/thread.php index eebe7be..2f4294f 100755 --- a/examples/thread.php +++ b/examples/thread.php @@ -16,7 +16,7 @@ Loop::run(function () { try { // Create a new child thread that does some blocking stuff. - $context = Thread::run(function (Channel $channel): \Generator { + $context = yield Thread::run(function (Channel $channel): \Generator { \printf("Received the following from parent: %s\n", yield $channel->receive()); print "Sleeping for 3 seconds...\n"; @@ -30,6 +30,8 @@ Loop::run(function () { return 42; }); + \assert($context instanceof Thread); + print "Waiting 2 seconds to send start data...\n"; yield new Delayed(2000); diff --git a/examples/threaded-parcel.php b/examples/threaded-parcel.php index 0baf9e5..6df8041 100755 --- a/examples/threaded-parcel.php +++ b/examples/threaded-parcel.php @@ -12,7 +12,7 @@ use Amp\Parallel\Sync\ThreadedParcel; Loop::run(function () { $parcel = new ThreadedParcel(1); - $context = Thread::run(function (Channel $channel, Parcel $parcel) { + $context = yield Thread::run(function (Channel $channel, Parcel $parcel) { $value = yield $parcel->synchronized(function (int $value) { return $value + 1; }); @@ -29,6 +29,8 @@ Loop::run(function () { }); }, $parcel); + \assert($context instanceof Thread); + yield new Delayed(100); // Give the thread time to start and access the parcel. yield $parcel->synchronized(function (int $value) {