Skip to content

Commit

Permalink
Add buffer size parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Aug 3, 2024
1 parent 0e940e6 commit 25c7662
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ function synchronized(Semaphore $semaphore, \Closure $synchronized, mixed ...$ar
}

/**
* @param int $bufferSize Number of channel items to buffer in memory before back-pressure is applied.
* @return array{Channel, Channel}
*/
function createChannelPair(): array
function createChannelPair(int $bufferSize = 0): array
{
$west = new Queue();
$east = new Queue();
$west = new Queue($bufferSize);
$east = new Queue($bufferSize);

return [
new ConcurrentIteratorChannel($west->iterate(), $east),
Expand Down

0 comments on commit 25c7662

Please sign in to comment.