notifyAll method

void notifyAll()

Wake up all currently waiting tasks (does not store permits).

Immediately wakes all tasks currently waiting on notified. Unlike notifyOne, this does not store permits for future waiters.

Use cases:

  • Broadcast shutdown signal
  • Configuration reload for all workers
  • "Check your state" broadcast

Example:

// ignore_for_file: unused_element

import 'package:cross_channel/notify.dart';

void main() {
  final shutdownFlag = Notify();

  // Graceful shutdown - wake all workers
  void initiateShutdown() {
    shutdownFlag.notifyAll(); // All workers check shutdown state
  }
}

Implementation

void notifyAll() {
  if (_closed) return;
  _epoch++;
  while (_waiters.isNotEmpty) {
    final c = _waiters.removeLast();
    if (!c.isCompleted) c.complete();
  }
}