LonghornPHP 2026

parallel\Channel::open

(0.9.0)

parallel\Channel::openAcceso

Descripción

public function parallel\Channel::open(string $name): Channel

Abre el canal con el nombre dado.

Excepciones

Advertencia

Lanza una parallel\Channel\Error\Existence si el canal no existe.

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes 1 note

up
1
gam6itko
4 years ago
<?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;
+add a note

AltStyle によって変換されたページ (->オリジナル) /