toMpmc<T> method

(MpmcSender<T>, MpmcReceiver<T>) toMpmc<T>({
  1. int? capacity,
  2. DropPolicy policy = DropPolicy.block,
  3. OnDrop<T>? onDrop,
  4. bool chunked = true,
  5. bool strict = true,
  6. String? metricsId,
})

Convert port messages to MPMC channel (legacy method).

Deprecated: Use toChannel with type: ChannelType.mpmc for new code. When strict == true, the port is closed on unexpected message types.

Implementation

(MpmcSender<T>, MpmcReceiver<T>) toMpmc<T>({
  int? capacity,
  DropPolicy policy = DropPolicy.block,
  OnDrop<T>? onDrop,
  bool chunked = true,
  bool strict = true,
  String? metricsId,
}) {
  final (tx, rx) = Mpmc.channel<T>(
    capacity: capacity,
    policy: policy,
    onDrop: onDrop,
    chunked: chunked,
    metricsId: metricsId,
  );
  listen((msg) {
    if (msg is T) {
      final r = tx.trySend(msg);
      if (r.isDisconnected) close();
    } else if (strict) {
      close();
    }
  });
  return (tx, rx);
}