close method

void close()

Undeclares the advanced subscriber and releases native resources.

Safe to call multiple times -- subsequent calls are no-ops.

Implementation

void close() {
  if (_closed) return;
  _closed = true;
  bindings.zd_advanced_subscriber_drop(_ptr.cast());
  // closeAndDrain, not a bare port close: a retained handle that arrived and
  // was never delivered has no other owner, so this is its only release.
  _sampleChannel.closeAndDrain();
  _missPort?.close();
  unawaited(_missController?.close());
  _detectChannel?.closeAndDrain();
  calloc.free(_ptr);
}