note 126459 deleted from parallel-channel.open by salathe

From: Date: Sun, 26 Sep 2021 08:59:50 +0000
Subject: note 126459 deleted from parallel-channel.open by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217008@lists.php.net to get a copy of this message
Note Submitter: gam6itko ---- <?php // example below shows how to get channel by name within child thread with Channel::open() use parallel\{Channel, Runtime}; $fnThread = static function () { $channel = Channel::open('channel_name'); $message = $channel->recv(); echo "- received message: $message\n"; return 'bye'; }; $channel = Channel::make('channel_name', 1); // main thread $runtime = new Runtime(); $future = $runtime->run($fnThread, [$channel]); echo "sending message\n"; $channel->send('hello future!'); sleep(1); echo "closing channel\n"; $channel->close(); echo "future said: ".$future->value(); echo PHP_EOL;

« previous php.notes (#217008) next »