sendTracked method

NativeWriteReceipt sendTracked(
  1. int connectionId,
  2. NativeOwnedBuffer buffer, {
  3. bool transfer = false,
})

A positive receipt reports queue acceptance. Its Written outcome requires a complete write and flush. Transfers are consumed on native rejection, including receipt quota exhaustion; retained sends preserve the original.

Implementation

NativeWriteReceipt sendTracked(
  int connectionId,
  NativeOwnedBuffer buffer, {
  bool transfer = false,
}) {
  _requireWriteCompletion();
  RangeError.checkValueInInterval(
    connectionId,
    1,
    0x7fffffff,
    'connectionId',
  );
  buffer._handle.check();
  if (buffer._handle.api._identity != _identity) {
    throw ArgumentError('Buffer belongs to a different native library');
  }
  final submitted = transfer ? buffer : buffer.retain();
  final receipt = _sendTracked(connectionId, submitted._handle.consume());
  _check(receipt);
  if (receipt == 0) throw StateError('Native writer returned no receipt');
  return NativeWriteReceipt._(this, receipt);
}