close method
void
close()
Undeclares the queryable and releases native resources.
Any query that arrived but was never delivered to a listener is
dropped, not delivered. Dropping a query is remotely visible: canon
sends the getter its ResponseFinal when the z_owned_query_t is
dropped, so a querier sees its query finalised promptly instead of
waiting out its timeout. That is the intended behaviour of a closed
queryable — the alternative is a native block nobody can ever free.
Safe to call multiple times -- subsequent calls are no-ops.
Implementation
void close() {
if (_closed) return;
_closed = true;
// Undeclare FIRST: once canon has dropped the closure no further query is
// posted, so the drain below faces a bounded queue rather than a moving
// target.
bindings.zd_queryable_drop(_ptr.cast());
_channel.closeAndDrain();
calloc.free(_ptr);
}