processCommands method

void processCommands()

Implementation

void processCommands() {
  // process cmd queue
  while (_shouldRun && _cmdQueue.isNotEmpty) {
    final cmd = _cmdQueue.removeFirst();

    try {
      if (cmd is _AddCmd) {
        _add(
          listenerId: cmd.listenerIdentity,
          fd: cmd.fd,
          flags: cmd.flags,
          callback: cmd.callback,
          callbackContext: cmd.callbackContext,
        );
      } else if (cmd is _ModCmd) {
        _mod(
          listenerId: cmd.listenerIdentity,
          flags: cmd.flags,
          callback: cmd.callback,
        );
      } else if (cmd is _DelCmd) {
        _del(
          listenerId: cmd.listenerIdentity,
        );
      } else if (cmd is _StopCmd) {
        _shouldRun = false;
      } else {
        assert(false);
      }

      _replySuccess(cmd);
    } on Exception catch (e, stackTrace) {
      _replyError(
        cmd,
        error: e,
        stackTrace: stackTrace,
      );
    }
  }
}