Takes over the initial ownership of a closure. Each closure is
initially created in a "floating" state, which means that the initial
reference count is not owned by any caller. Closure.sink checks
to see if the object is still floating, and if so, unsets the
floating state and decreases the reference count. If the closure
is not floating, Closure.sink does nothing. The reason for the
existence of the floating state is to prevent cumbersome code
sequences like:
closure = g_cclosure_new (cb_func, cb_data);
g_source_set_closure (source, closure);
g_closure_unref (closure); // GObject doesn't really need this
ecause Source.setClosure (and similar functions) take ownership of the
initial reference count, if it is unowned, we instead can write:
Because Closure.sink may decrement the reference count of a closure
(if it hasn't been called on closure yet) just like Closure.unref,
Closure.ref should be called prior to this function.
Takes over the initial ownership of a closure. Each closure is initially created in a "floating" state, which means that the initial reference count is not owned by any caller. Closure.sink checks to see if the object is still floating, and if so, unsets the floating state and decreases the reference count. If the closure is not floating, Closure.sink does nothing. The reason for the existence of the floating state is to prevent cumbersome code sequences like:
closure = g_cclosure_new (cb_func, cb_data); g_source_set_closure (source, closure); g_closure_unref (closure); // GObject doesn't really need this
ecause Source.setClosure (and similar functions) take ownership of the initial reference count, if it is unowned, we instead can write:
Generally, this function is used together with Closure.ref. Ane example of storing a closure for later notification looks like:
Because Closure.sink may decrement the reference count of a closure (if it hasn't been called on closure yet) just like Closure.unref, Closure.ref should be called prior to this function.