threadsAddIdleFull

Adds a function to be called whenever there are no higher priority events pending. If the function returns FALSE it is automatically removed from the list of event sources and will not be called again.

This variant of Idle.addFull calls function with the GDK lock held. It can be thought of a MT-safe version for GTK+ widgets for the following use case, where you have to worry about idle_callback() running in thread A and accessing self after it has been finalized in thread B:

static gboolean
idle_callback (gpointer data)
{
// [gdk.Threads.Threads.enter|Threads.enter]; would be needed for [glib.Idle.Idle.add|Idle.add]

SomeWidget *self = data;
// do stuff with self

self->idle_id = 0;

// [gdk.Threads.Threads.leave|Threads.leave]; would be needed for [glib.Idle.Idle.add|Idle.add]
return FALSE;
}

static void
some_widget_do_stuff_later (SomeWidget *self)
{
self->idle_id = gdk_threads_add_idle (idle_callback, self)
// using [glib.Idle.Idle.add|Idle.add] here would require thread protection in the callback
}

static void
some_widget_finalize (GObject *object)
{
SomeWidget *self = SOME_WIDGET (object);
if (self->idle_id)
g_source_remove (self->idle_id);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
uint
threadsAddIdleFull

Parameters

priority int

the priority of the idle source. Typically this will be in the range between G_PRIORITY_DEFAULT_IDLE and G_PRIORITY_HIGH_IDLE

function_ GSourceFunc

function to call

data void*

data to pass to function

notify GDestroyNotify

function to call when the idle is removed, or NULL

Return Value

Type: uint

the ID (greater than 0) of the event source.

Meta

Since

2.12