class BroadcastBatcher

Own the sender while generation and its database transactions stay in the caller.

Properties

protected StreamEvent, int}> $channel
protected WaitConcurrent $concurrent
protected Throwable|null $failure

Methods

__construct(Closure $send, Closure|null $runner, int $milliseconds, int $maxBytes)

Start one sender in the operation's captured context.

void
push(StreamEvent $event)

Queue an original event without allowing an unbounded backlog.

void
finish()

Drain accepted events and wait for the sender to finish.

void
cancel()

Cancel the owned sender without draining after parent cancellation.

void
drain(Closure $send)

Send compatible queued text without extending the first arrival's deadline.

array|false
read(int|null $deadline = null)

Read an available event or wait until the current batch's deadline.

bool
isBatchable(StreamEvent $event)

Identify plain deltas without additional event semantics.

bool
isCompatible(TextDelta|ReasoningDelta $first, TextDelta|ReasoningDelta $event)

Match the invocation and content block of adjacent deltas.

Details

at line 40
__construct(Closure $send, Closure|null $runner, int $milliseconds, int $maxBytes)

Start one sender in the operation's captured context.

Parameters

Closure $send
Closure|null $runner
int $milliseconds
int $maxBytes

at line 70
void push(StreamEvent $event)

Queue an original event without allowing an unbounded backlog.

Parameters

StreamEvent $event

Return Value

void

at line 95
void finish()

Drain accepted events and wait for the sender to finish.

Return Value

void

at line 122
void cancel()

Cancel the owned sender without draining after parent cancellation.

Return Value

void

at line 133
protected void drain(Closure $send)

Send compatible queued text without extending the first arrival's deadline.

Parameters

Closure $send

Return Value

void

at line 182
protected array|false read(int|null $deadline = null)

Read an available event or wait until the current batch's deadline.

Parameters

int|null $deadline

Return Value

array|false

at line 218
protected bool isBatchable(StreamEvent $event)

Identify plain deltas without additional event semantics.

Parameters

StreamEvent $event

Return Value

bool

at line 227
protected bool isCompatible(TextDelta|ReasoningDelta $first, TextDelta|ReasoningDelta $event)

Match the invocation and content block of adjacent deltas.

Parameters

TextDelta|ReasoningDelta $first
TextDelta|ReasoningDelta $event

Return Value

bool