$capacity 是缓冲区中堆栈的数量。
例如
<?php
use parallel\{Channel,Runtime};
$test = function($ch){
var_dump($ch->Recv());
var_dump($ch->Recv());
var_dump($ch->Recv());
echo 'Sleep'.PHP_EOL;
sleep(3);
echo 'Call Recv()'.PHP_EOL;
var_dump($ch->Recv());
};
$t1 = new Runtime();
$ch = new Channel(3); $ch->Send('abc1');
$ch->Send('abc2');
$ch->Send('abc3');
$t1->Run($test,[$ch]);
sleep(1);
echo 'Wait for Recv()...'.PHP_EOL;
$ch->Send('abc4'); ?>
结果
string(4) "abc1"
string(4) "abc2"
string(4) "abc3"
Sleep
Wait for Recv()...
Call Recv()
string(4) "abc4"