note 126458 added to parallel-channel.open

From: Date: Sat, 25 Sep 2021 21:58:50 +0000
Subject: note 126458 added to parallel-channel.open
Groups: php.notes 
Request: Send a blank email to php-notes+get-217003@lists.php.net to get a copy of this message
<?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; ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 176.104.221.149) ---- Manual Page -- https://php.net/manual/en/parallel-channel.open.php Edit -- https://main.php.net/note/edit/126458 Del: integrated -- https://main.php.net/note/delete/126458/integrated Del: useless -- https://main.php.net/note/delete/126458/useless Del: bad code -- https://main.php.net/note/delete/126458/bad+code Del: spam -- https://main.php.net/note/delete/126458/spam Del: non-english -- https://main.php.net/note/delete/126458/non-english Del: in docs -- https://main.php.net/note/delete/126458/in+docs Del: other reasons-- https://main.php.net/note/delete/126458 Reject -- https://main.php.net/note/reject/126458 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217003) next »