GLib.Source.set_dispose_function

### Method

# GLib Sourceset_dispose_function

since: 2.64

#### Declaration

    void
    g_source_set_dispose_function (
      GSource* source,
      GSourceDisposeFunc dispose
    )

#### Description

Set `dispose` as dispose function on `source`. `dispose` will be called once the reference count of `source` reaches 0 but before any of the state of the source is freed, especially before the finalize function is called.

This means that at this point `source` is still a valid `GSource` and it is allow for the reference count to increase again until `dispose` returns.

The dispose function can be used to clear any “weak” references to the `source` in other data structures in a thread-safe way where it is possible for another thread to increase the reference count of `source` again while it is being freed.

The finalize function can not be used for this purpose as at that point `source` is already partially freed and not valid anymore.

This should only ever be called from `GSource` implementations.

Available since: 2.64

This method is not directly available to language bindings.

#### Parameters

`dispose`

  Type: `GSourceDisposeFunc`

  `GSourceDisposeFunc` to set on the source.