MainContext
Object Hierarchy:
Description:
[ Compact ]
public class MainContext
The `GMainContext` struct is an opaque data type representing a set of sources to be handled in a main loop.
Content:
Static methods:
- public static weak MainContext @default ()
Returns the global default main context.
- public static weak Source current_source ()
Returns the currently firing source for this thread.
- public static weak MainContext? get_thread_default ()
Gets the thread-default MainContext for
this thread.
- public static MainContext ref_thread_default ()
Gets the thread-default MainContext for
this thread, as with get_thread_default, but also adds a
reference to it with g_main_context_ref
.
Creation methods:
Methods:
- public bool iteration (bool may_block)
Runs a single iteration for the given main loop.
- public bool pending ()
Checks if any sources have pending events for the given context.
- public weak Source find_source_by_id (uint source_id)
- public weak Source find_source_by_user_data (void* user_data)
Finds a source with the given user data for the callback.
- public weak Source find_source_by_funcs_user_data (SourceFuncs funcs, void* user_data)
Finds a source with the given source functions and user data.
- public void wakeup ()
If this is currently blocking in
iteration waiting for a source to become ready, cause it to stop blocking
and return.
- public bool acquire ()
Tries to become the owner of the specified context.
- public void release ()
Releases ownership of a context previously acquired by this thread
with acquire.
- public bool is_owner ()
Determines whether this thread holds the (recursive) ownership of this
MainContext.
- public bool wait (Cond cond, Mutex mutex)
Tries to become the owner of the specified context, as with
acquire.
- public bool prepare (out int priority)
Prepares to poll sources within a main loop.
- public int query (int max_priority, out int timeout_, PollFD[] fds)
Determines information necessary to poll this main loop.
- public int check (int max_priority, PollFD[] fds, int n_fds)
Passes the results of polling back to the main loop.
- public void dispatch ()
Dispatches all pending sources.
- public void set_poll_func (PollFunc func)
Sets the function to use to handle polling of file descriptors.
- public PollFunc get_poll_func ()
- public void add_poll (ref PollFD fd, int priority)
Adds a file descriptor to the set of file descriptors polled for this
context.
- public void remove_poll (ref PollFD fd)
Removes file descriptor from the set of file descriptors to be polled
for a particular context.
- public int depth ()
- public void push_thread_default ()
Acquires this and sets it as the
thread-default context for the current thread.
- public void pop_thread_default ()
Pops this off the thread-default
context stack (verifying that it was on the top of the stack).
- public void invoke (owned SourceFunc function, int priority = DEFAULT)
- public void invoke_full (int priority, owned SourceFunc function)
Invokes a function in such a way that this
is owned during the invocation of function
.