From 25c76626532f3d263023cc13170eb109aebfbeeb Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sat, 3 Aug 2024 14:24:14 -0500 Subject: [PATCH] Add buffer size parameter --- src/functions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/functions.php b/src/functions.php index 3090be9..1b482e6 100644 --- a/src/functions.php +++ b/src/functions.php @@ -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),