libtcspc.MergeN

final class libtcspc.MergeN(inputs, *event_types, max_buffered=65536, numeric_traits=None)[source]

Bases: Node

Merges N sorted input streams into one, ordered by abstime.

Events arriving on the inputs are buffered and emitted in non-decreasing abstime order. Unlike Merge, the relative order of events with equal abstime is not guaranteed.

Parameters:
  • inputs (int or Sequence[str]) – The input ports. An integer N creates N ports named "input-0" through "input-(N-1)". A sequence of names creates ports with those exact names. Must specify at least two inputs.

  • *event_types (EventType) – The event types to merge. Every event handled must carry an abstime member; the merge buffers and sorts by it.

  • max_buffered (int or Param[int]) – The maximum number of events to buffer from a single input before another input must produce an event. Default: 65536.

  • numeric_traits (NumericTraits or None) – Set of integer types parameterising the merge (in particular the abstime_type). None (the default) uses NumericTraits defaults.

Notes

All inputs must be fed internally (for example by a Route or Broadcast that fans out a single external input); a merge cannot serve as the executable graph’s external input.

All inputs must be driven on the same thread (the underlying C++ merge_n shares unsynchronized state across its input ports). This is enforced when the graph is compiled: a merge fed from two threads — for example with a Buffer on only one branch — is rejected.

Events handled:

  • Events matching one of event_types: buffered and emitted in non-decreasing abstime order.

  • Events not in event_types: rejected at graph build time.

  • End of input: flushes any buffered events, then propagates.

See also

tcspc::merge_n()

The underlying C++ factory function.

Merge

2-way sorted merge that guarantees input-0 precedes input-1 on equal abstime.

MergeNUnsorted

N-way pass-through merge that does no sorting or buffering.