LeastFullForkPolicy

class LeastFullForkPolicy<T>(tags: Iterable<OutputTag<Container<*>>> = generateSequence { newDynamicOutputTag { it.walkDownstream().filterIsInstance<Container<*>>().first() } } .asIterable()) : ForkPolicy<T>

Fork policy that routes each entity to the destination with the least occupancy. Helps balance load across multiple branches.

Parameters

T

the type of entities being routed

tags

the tags used to identify downstream containers for each destination

Constructors

Link copied to clipboard
constructor(tags: Iterable<OutputTag<Container<*>>> = generateSequence { newDynamicOutputTag { it.walkDownstream().filterIsInstance<Container<*>>().first() } } .asIterable())

Functions

Link copied to clipboard
open override fun allClosed(): Boolean

Checks if all destination channels are closed.

Link copied to clipboard
context(_: Simulator)
open override fun initialize(source: PushInputChannel<T>, destinations: List<PushOutputChannel<T>>)

Initializes the policy with the source and destination channels. Sets up initial state and event listeners for channel open/close events.

Link copied to clipboard
open override fun onChannelClose(channel: PushOutputChannel<T>)

Called when a destination channel closes.

Link copied to clipboard
open override fun onChannelOpen(channel: PushOutputChannel<T>)

Called when a destination channel opens.

Link copied to clipboard
open override fun selectChannel(obj: T): PushOutputChannel<T>

Selects the destination channel for an entity.