This function essentially limits the life time of the closure
to the life time of the object.
That is, when the object is finalized, the closure
is invalidated by calling
invalidate on it, in order to prevent invocations of the closure with a
finalized (nonexisting) object. Also, @ref and
unref are added as marshal guards to the closure
, to ensure that an extra
reference count is held on this during invocation of the closure
. Usually, this function
will be called on closures that use this this as closure data.
this |
Object restricting lifetime of |
closure |
Closure to watch |