glib.main_context

Module for [MainContext] class

Types 1

The [glib.main_context.MainContext] struct is an opaque data type representing a set of sources to be handled in a main loop.

Methods
void * _cPtr(Flag!"Dup" dup = No.Dup)
GType _gType() @property
MainContext self()Returns `this`, for use in `with` statements.
glib.main_context.MainContext newWithFlags(glib.types.MainContextFlags flags)Creates a new #GMainContext structure.
bool acquire()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 aga...
void addPoll(glib.types.PollFD fd, int priority)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 [glib.source.Source.addUnixFd] instead.
bool check(int maxPriority, glib.types.PollFD[] fds)Passes the results of polling back to the main loop. You should be careful to pass fds and its length nfds as received from [glib.maincontext.MainContext.query], as this functions relies on assumpt...
void dispatch()Dispatches all pending sources.
glib.source.Source findSourceByFuncsUserData(glib.types.SourceFuncs funcs, void * userData = null)Finds a source with the given source functions and user data. If multiple sources exist with the same source function and user data, the first one found will be returned.
glib.source.Source findSourceById(uint sourceId)Finds a #GSource given a pair of context and ID.
glib.source.Source findSourceByUserData(void * userData = null)Finds a source with the given user data for the callback. If multiple sources exist with the same user data, the first one found will be returned.
void invokeFull(int priority, glib.types.SourceFunc function_)Invokes a function in such a way that context is owned during the invocation of function.
bool isOwner()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. Retur...
bool iteration(bool mayBlock)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 mayblock is true, waiting for ...
bool pending()Checks if any sources have pending events for the given context. Returns: true if events are pending.
void popThreadDefault()Pops context off the thread-default context stack (verifying that it was on the top of the stack).
bool prepare(out int priority)Prepares to poll sources within a main loop. The resulting information for polling is determined by calling gmaincontext_query ().
void pushThreadDefault()Acquires context and sets it as the thread-default context for the current thread. This will cause certain asynchronous operations (such as most [gio][gio]-based I/O) which are started in this thre...
int query(int maxPriority, out int timeout, ref glib.types.PollFD[] fds)Determines information necessary to poll this main loop. You should be careful to pass the resulting fds array and its length nfds as is when calling [glib.maincontext.MainContext.check], as this f...
void release()Releases ownership of a context previously acquired by this thread with [glib.maincontext.MainContext.acquire]. If the context was acquired multiple times, the ownership will be released only when ...
void removePoll(glib.types.PollFD fd)Removes file descriptor from the set of file descriptors to be polled for a particular context.
void wakeup()If context is currently blocking in [glib.maincontext.MainContext.iteration] waiting for a source to become ready, cause it to stop blocking and return. Otherwise, cause the next invocation of [gl...
glib.main_context.MainContext default_()Returns the global-default main context. This is the main context used for main loop functions when a main loop is not explicitly specified, and corresponds to the "main" main loop. See also [glib....
glib.main_context.MainContext getThreadDefault()Gets the thread-default #GMainContext for this thread. Asynchronous operations that want to be able to be run in contexts other than the default one should call this method or [glib.main_context.Ma...
glib.main_context.MainContext refThreadDefault()Gets the thread-default #GMainContext for this thread, as with [glib.maincontext.MainContext.getThreadDefault], but also adds a reference to it with [glib.maincontext.MainContext.ref]. In addition,...
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new #GMainContext structure. Returns: the new #GMainContext