[ Compact ]
public class MainContext
public class MainContext
The `GMainContext` struct is an opaque data type representing a set of sources to be handled in a main loop.
- 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
- public MainContext ()
Creates a new MainContext structure.
- 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)
Finds a SignalSource given a pair of context and 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 bool check (int max_priority, PollFD 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 ()
Gets the poll function set by set_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