MainContext

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

The GMainContext struct is an opaque data type representing a set of sources to be handled in a main loop.

Skipped during bindings generation

  • parameter fds: PollFD

  • parameter user_data: gpointer

  • parameter user_data: gpointer

  • parameter priority: priority: Out parameter is not supported

  • parameter timeout_: timeout_: Out parameter is not supported

  • parameter mutex: Mutex

Constructors

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

Types

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

Properties

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

Functions

Link copied to clipboard

Tries to become the owner of the specified context. If some other thread is the owner of the context, returns false immediately. Ownership is properly recursive: the owner can require ownership again and will release ownership when g_main_context_release() is called as many times as g_main_context_acquire().

Link copied to clipboard
fun addPoll(fd: PollFD, priority: Int)

Adds a file descriptor to the set of file descriptors polled for this context. This will very seldom be used directly. Instead a typical event source will use g_source_add_unix_fd() instead.

Link copied to clipboard
fun dispatch()

Dispatches all pending sources.

Link copied to clipboard
fun findSourceById(sourceId: <Error class: unknown class>): Source

Finds a #GSource given a pair of context and ID.

Link copied to clipboard
fun invokeFull(priority: Int, function: SourceFunc)

Invokes a function in such a way that @context is owned during the invocation of @function.

Link copied to clipboard

Determines whether this thread holds the (recursive) ownership of this #GMainContext. This is useful to know before waiting on another thread that may be blocking to get ownership of @context.

Link copied to clipboard
fun iteration(mayBlock: Boolean): Boolean

Runs a single iteration for the given main loop. This involves checking to see if any event sources are ready to be processed, then if no events sources are ready and @may_block is true, waiting for a source to become ready, then dispatching the highest priority events sources that are ready. Otherwise, if @may_block is false sources are not waited to become ready, only those highest priority events sources will be dispatched (if any), that are ready at this given moment without further waiting.

Link copied to clipboard

Checks if any sources have pending events for the given context.

Link copied to clipboard

Pops @context off the thread-default context stack (verifying that it was on the top of the stack).

Link copied to clipboard

Acquires @context and sets it as the thread-default context for the current thread. This will cause certain asynchronous operations (such as most gio-based I/O) which are started in this thread to run under @context and deliver their results to its main loop, rather than running under the global default context in the main thread. Note that calling this function changes the context returned by g_main_context_get_thread_default(), not the one returned by g_main_context_default(), so it does not affect the context used by functions like g_idle_add().

Link copied to clipboard

Increases the reference count on a #GMainContext object by one.

Link copied to clipboard
fun release()

Releases ownership of a context previously acquired by this thread with g_main_context_acquire(). If the context was acquired multiple times, the ownership will be released only when g_main_context_release() is called as many times as it was acquired.

Link copied to clipboard

Removes file descriptor from the set of file descriptors to be polled for a particular context.

Link copied to clipboard
fun unref()

Decreases the reference count on a #GMainContext object by one. If the result is zero, free the context and free all associated memory.

Link copied to clipboard
fun wakeup()

If @context is currently blocking in g_main_context_iteration() waiting for a source to become ready, cause it to stop blocking and return. Otherwise, cause the next invocation of g_main_context_iteration() to return without blocking.