receive method

  1. @override
Future<T> receive()
override

Implementation

@override Future<T> receive() async {
  if (_isClosed && _data.isEmpty) {
    throw ChannelException.closed();
  }

  if (_data.isNotEmpty) {
    return _data.top();
  }

  final completer = Completer<T>();
  _completers.add(completer);

  return completer.future;
}