Source

class Source(pointer: <Error class: unknown class><<Error class: unknown class>>) : Record

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

Skipped during bindings generation

  • method add_unix_fd: Return type gpointer is unsupported

  • parameter tag: gpointer

  • parameter tag: gpointer

  • parameter tag: gpointer

  • parameter callback_data: gpointer

  • parameter user_data: gpointer

  • parameter user_data: gpointer

  • field callback_data: Record field callback_data is private

  • field callback_funcs: Record field callback_funcs is private

  • field source_funcs: Record field source_funcs is private

  • field ref_count: Record field ref_count is private

  • field context: Record field context is private

  • field priority: Record field priority is private

  • field flags: Record field flags is private

  • field source_id: Record field source_id is private

  • field poll_fds: Record field poll_fds is private

  • field prev: Record field prev is private

  • field next: Record field next is private

  • field name: Record field name is private

  • field priv: Record field priv is private

Constructors

Link copied to clipboard
constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion : RecordCompanion<Source, <Error class: unknown class>>

Properties

Link copied to clipboard
val glibSourcePointer: <Error class: unknown class><<Error class: unknown class>>

Functions

Link copied to clipboard
fun addChildSource(childSource: 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

Link copied to clipboard
fun addPoll(fd: PollFD)

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.

Link copied to clipboard
fun attach(context: MainContext? = null): <Error class: unknown class>

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

Link copied to clipboard
fun 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.

Link copied to clipboard

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

Link copied to clipboard

Gets the #GMainContext with which the source is associated.

Link copied to clipboard
fun getCurrentTime(timeval: TimeVal)

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

Link copied to clipboard
fun getId(): <Error class: unknown class>

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().

Link copied to clipboard
fun getName(): String?

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().

Link copied to clipboard

Gets the priority of a source.

Link copied to clipboard

Gets the "ready time" of @source, as set by g_source_set_ready_time().

Link copied to clipboard
fun getTime(): Long

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.

Link copied to clipboard

Returns whether @source has been destroyed.

Link copied to clipboard
fun ref(): Source

Increases the reference count on a source by one.

Link copied to clipboard
fun removeChildSource(childSource: Source)

Detaches @child_source from @source and destroys it.

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard
fun setCanRecurse(canRecurse: Boolean)

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.

Link copied to clipboard
fun setFuncs(funcs: SourceFuncs)

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

Link copied to clipboard
fun setName(name: String)

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

Link copied to clipboard
fun setPriority(priority: Int)

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.

Link copied to clipboard
fun setReadyTime(readyTime: Long)

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.

Link copied to clipboard

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

Link copied to clipboard
fun 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.