note 124204 added to class.parallel-channel

From: Date: Wed, 18 Sep 2019 04:08:12 +0000
Subject: note 124204 added to class.parallel-channel
Groups: php.notes 
Request: Send a blank email to php-notes+get-212240@lists.php.net to get a copy of this message
<?php use parallel\Channel; function sum(array $a, Channel $ch) { $sum=0; foreach ($a as $v) { $sum+=$v; } $ch->send($sum); } try { $a=[7, 2, 8, 1, 4, 0, 9, 10]; $ch1=Channel::make('sum', 2); $ch2=new Channel; $num=count($a) / 2; sum(array_slice($a, 0, $num), $ch1); sum(array_slice($a, $num), $ch1); //receive from channel $x=$ch1->recv(); $y=$ch1->recv(); $ch1->close(); echo "\nch1:", $x, "\t", $y, "\t", $x + $y, "\n"; } catch(Error $err) { echo "\nError:", $err->getMessage(); } catch(Exception $e) { echo "\nException:", $e->getMessage(); } ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.168 (proxied: 115.199.120.196) ---- Manual Page -- http://php.net/manual/en/class.parallel-channel.php Edit -- https://master.php.net/note/edit/124204 Del: integrated -- https://master.php.net/note/delete/124204/integrated Del: useless -- https://master.php.net/note/delete/124204/useless Del: bad code -- https://master.php.net/note/delete/124204/bad+code Del: spam -- https://master.php.net/note/delete/124204/spam Del: non-english -- https://master.php.net/note/delete/124204/non-english Del: in docs -- https://master.php.net/note/delete/124204/in+docs Del: other reasons-- https://master.php.net/note/delete/124204 Reject -- https://master.php.net/note/reject/124204 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#212240) next »