Struct

GLibSource

Description [src]

struct GSource {
  /* No available fields */
}

The GSource struct is an opaque data type representing an event source.

Constructors

g_source_new

Creates a new GSource structure. The size is specified to allow creating structures derived from GSource that contain additional data. The size passed in must be at least sizeof (GSource).

Functions

g_source_remove

Removes the source with the given ID from the default main context. You must use g_source_destroy() for sources added to a non-default main context.

g_source_remove_by_funcs_user_data

Removes a source from the default main loop context given the source functions and user data. If multiple sources exist with the same source functions and user data, only one will be destroyed.

g_source_remove_by_user_data

Removes a source from the default main loop context given the user data for the callback. If multiple sources exist with the same user data, only one will be destroyed.

g_source_set_name_by_id

Sets the name of a source using its ID.

since: 2.26

Instance methods

g_source_add_child_source

Adds child_source to source as a “polled” source; when source is added to a GMainContext, child_source will be automatically added with the same priority, when child_source is triggered, it will cause source to dispatch (in addition to calling its own callback), and when source is destroyed, it will destroy child_source as well. (source will also still be dispatched if its own prepare/check functions indicate that it is ready.).

since: 2.28

g_source_add_poll

Adds a file descriptor to the set of file descriptors polled for this source. This is usually combined with g_source_new() to add an event source. The event source’s check function will typically test the revents field in the GPollFD struct and return TRUE if events need to be processed.

g_source_add_unix_fd

Monitors fd for the IO events in events.

since: 2.36

g_source_attach

Adds a GSource to a context so that it will be executed within that context. Remove it by calling g_source_destroy().

g_source_destroy

Removes a source from its GMainContext, if any, and mark it as destroyed. The source cannot be subsequently added to another context. It is safe to call this on sources which have already been removed from their context.

g_source_get_can_recurse

Checks whether a source is allowed to be called recursively. see g_source_set_can_recurse().

g_source_get_context

Gets the GMainContext with which the source is associated.

g_source_get_current_time

This function ignores source and is otherwise the same as g_get_current_time().

deprecated: 2.28 

g_source_get_id

Returns the numeric ID for a particular source. The ID of a source is a positive integer which is unique within a particular main loop context. The reverse mapping from ID to source is done by g_main_context_find_source_by_id().

g_source_get_name

Gets a name for the source, used in debugging and profiling. The name may be NULL if it has never been set with g_source_set_name().

since: 2.26

g_source_get_priority

Gets the priority of a source.

g_source_get_ready_time

Gets the “ready time” of source, as set by g_source_set_ready_time().

g_source_get_time

Gets the time to be used when checking this source. The advantage of calling this function over calling g_get_monotonic_time() directly is that when checking multiple sources, GLib can cache a single value instead of having to repeatedly get the system monotonic time.

since: 2.28

g_source_is_destroyed

Returns whether source has been destroyed.

since: 2.12

g_source_modify_unix_fd

Updates the event mask to watch for the fd identified by tag.

since: 2.36

g_source_query_unix_fd

Queries the events reported for the fd corresponding to tag on source during the last poll.

since: 2.36

g_source_ref

Increases the reference count on a source by one.

g_source_remove_child_source

Detaches child_source from source and destroys it.

since: 2.28

g_source_remove_poll

Removes a file descriptor from the set of file descriptors polled for this source.

g_source_remove_unix_fd

Reverses the effect of a previous call to g_source_add_unix_fd().

since: 2.36

g_source_set_callback

Sets the callback function for a source. The callback for a source is called from the source’s dispatch function.

g_source_set_callback_indirect

Sets the callback function storing the data as a refcounted callback “object”. This is used internally. Note that calling g_source_set_callback_indirect() assumes an initial reference count on callback_data, and thus callback_funcs->unref will eventually be called once more than callback_funcs->ref.

g_source_set_can_recurse

Sets whether a source can be called recursively. If can_recurse is TRUE, then while the source is being dispatched then this source will be processed normally. Otherwise, all processing of this source is blocked until the dispatch function returns.

g_source_set_dispose_function

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.

since: 2.64

g_source_set_funcs

Sets the source functions (can be used to override default implementations) of an unattached source.

since: 2.12

g_source_set_name

Sets a name for the source, used in debugging and profiling. The name defaults to NULL.

since: 2.26

g_source_set_priority

Sets the priority of a source. While the main loop is being run, a source will be dispatched if it is ready to be dispatched and no sources at a higher (numerically smaller) priority are ready to be dispatched.

g_source_set_ready_time

Sets a GSource to be dispatched when the given monotonic time is reached (or passed). If the monotonic time is in the past (as it always will be if ready_time is 0) then the source will be dispatched immediately.

since: 2.36

g_source_set_static_name

A variant of g_source_set_name() that does not duplicate the name, and can only be used with string literals.

since: 2.70

g_source_unref

Decreases the reference count of a source by one. If the resulting reference count is zero the source and associated memory will be destroyed.