Software: Apache/2.0.54 (Fedora). PHP/5.0.4 uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/share/gtk-doc/html/glib/ drwxr-xr-x |
Viewing file: Select action/file-type:
Synopsis#include <glib.h> GMainLoop; GMainLoop* g_main_loop_new (GMainContext *context, gboolean is_running); GMainLoop* g_main_loop_ref (GMainLoop *loop); void g_main_loop_unref (GMainLoop *loop); void g_main_loop_run (GMainLoop *loop); void g_main_loop_quit (GMainLoop *loop); gboolean g_main_loop_is_running (GMainLoop *loop); GMainContext* g_main_loop_get_context (GMainLoop *loop); #define g_main_new (is_running) #define g_main_destroy (loop) #define g_main_run (loop) #define g_main_quit (loop) #define g_main_is_running (loop) #define G_PRIORITY_HIGH #define G_PRIORITY_DEFAULT #define G_PRIORITY_HIGH_IDLE #define G_PRIORITY_DEFAULT_IDLE #define G_PRIORITY_LOW GMainContext; GMainContext* g_main_context_new (void); GMainContext* g_main_context_ref (GMainContext *context); void g_main_context_unref (GMainContext *context); GMainContext* g_main_context_default (void); gboolean g_main_context_iteration (GMainContext *context, gboolean may_block); #define g_main_iteration (may_block) gboolean g_main_context_pending (GMainContext *context); #define g_main_pending () GSource* g_main_context_find_source_by_id (GMainContext *context, guint source_id); GSource* g_main_context_find_source_by_user_data (GMainContext *context, gpointer user_data); GSource* g_main_context_find_source_by_funcs_user_data (GMainContext *context, GSourceFuncs *funcs, gpointer user_data); void g_main_context_wakeup (GMainContext *context); gboolean g_main_context_acquire (GMainContext *context); void g_main_context_release (GMainContext *context); gboolean g_main_context_wait (GMainContext *context, GCond *cond, GMutex *mutex); gboolean g_main_context_prepare (GMainContext *context, gint *priority); gint g_main_context_query (GMainContext *context, gint max_priority, gint *timeout_, GPollFD *fds, gint n_fds); gint g_main_context_check (GMainContext *context, gint max_priority, GPollFD *fds, gint n_fds); void g_main_context_dispatch (GMainContext *context); void g_main_context_set_poll_func (GMainContext *context, GPollFunc func); GPollFunc g_main_context_get_poll_func (GMainContext *context); gint (*GPollFunc) (GPollFD *ufds, guint nfsd, gint timeout_); void g_main_context_add_poll (GMainContext *context, GPollFD *fd, gint priority); void g_main_context_remove_poll (GMainContext *context, GPollFD *fd); int g_main_depth (void); #define g_main_set_poll_func (func) GSource* g_timeout_source_new (guint interval); guint g_timeout_add (guint interval, GSourceFunc function, gpointer data); guint g_timeout_add_full (gint priority, guint interval, GSourceFunc function, gpointer data, GDestroyNotify notify); GSource* g_idle_source_new (void); guint g_idle_add (GSourceFunc function, gpointer data); guint g_idle_add_full (gint priority, GSourceFunc function, gpointer data, GDestroyNotify notify); gboolean g_idle_remove_by_data (gpointer data); typedef GPid; void (*GChildWatchFunc) (GPid pid, gint status, gpointer data); GSource* g_child_watch_source_new (GPid pid); guint g_child_watch_add (GPid pid, GChildWatchFunc function, gpointer data); guint g_child_watch_add_full (gint priority, GPid pid, GChildWatchFunc function, gpointer data, GDestroyNotify notify); GPollFD; GSource; void (*GSourceDummyMarshal) (void); GSourceFuncs; GSourceCallbackFuncs; GSource* g_source_new (GSourceFuncs *source_funcs, guint struct_size); GSource* g_source_ref (GSource *source); void g_source_unref (GSource *source); guint g_source_attach (GSource *source, GMainContext *context); void g_source_destroy (GSource *source); void g_source_set_priority (GSource *source, gint priority); gint g_source_get_priority (GSource *source); void g_source_set_can_recurse (GSource *source, gboolean can_recurse); gboolean g_source_get_can_recurse (GSource *source); guint g_source_get_id (GSource *source); GMainContext* g_source_get_context (GSource *source); void g_source_set_callback (GSource *source, GSourceFunc func, gpointer data, GDestroyNotify notify); gboolean (*GSourceFunc) (gpointer data); void g_source_set_callback_indirect (GSource *source, gpointer callback_data, GSourceCallbackFuncs *callback_funcs); void g_source_add_poll (GSource *source, GPollFD *fd); void g_source_remove_poll (GSource *source, GPollFD *fd); void g_source_get_current_time (GSource *source, GTimeVal *timeval); gboolean g_source_remove (guint tag); gboolean g_source_remove_by_funcs_user_data (GSourceFuncs *funcs, gpointer user_data); gboolean g_source_remove_by_user_data (gpointer user_data); Description
The main event loop manages all the available sources of events for
GLib and GTK+ applications. These events can come from any number of
different types of sources such as file descriptors (plain files,
pipes or sockets) and timeouts. New types of event sources can also
be added using To allow multiple independent sets of sources to be handled in different threads, each source is associated with a GMainContext. A GMainContext can only be running in a single thread, but sources can be added to it and removed from it from other threads. Each event source is assigned a priority. The default priority, G_PRIORITY_DEFAULT, is 0. Values less than 0 denote higher priorities. Values greater than 0 denote lower priorities. Events from high priority sources are always processed before events from lower priority sources. Idle functions can also be added, and assigned a priority. These will be run whenever no events with a higher priority are ready to be processed.
The GMainLoop data type represents a main event loop. A GMainLoop
is created with It is possible to create new instances of GMainLoop recursively. This is often used in GTK+ applications when showing modal dialog boxes. Note that event sources are associated with a particular GMainContext, and will be checked and dispatched for all main loops associated with that GMainContext.
GTK+ contains wrappers of some of these functions, e.g. Creating new sources types
One of the unusual features of the GTK+ main loop functionality
is that new types of event source can be created and used in
addition to the builtin type of event source. A new event source
type is used for handling GDK events. A new source type is
created by deriving from the GSource
structure. The derived type of source is represented by a
structure that has the GSource structure as a first element,
and other elements specific to the new source type. To create
an instance of the new source type, call
New source types basically interact with with the main context
in two ways. Their prepare function in GSourceFuncs can set
a timeout to determine the maximum amount of time that the
main loop will sleep before checking the source again. In
addition, or as well, the source can add file descriptors to
the set that the main context checks using Customizing the main loop iteration
Single iterations of a GMainContext can be run with
The operation of these functions can best be seen in terms of a state diagram, as shown in Figure 1, “States of a Main Context”. DetailsGMainLooptypedef struct _GMainLoop GMainLoop; The GMainLoop struct is an opaque data type representing the main event loop of a GLib or GTK+ application. g_main_loop_new ()GMainLoop* g_main_loop_new (GMainContext *context, gboolean is_running); Creates a new GMainLoop structure.
g_main_loop_ref ()GMainLoop* g_main_loop_ref (GMainLoop *loop); Increases the reference count on a GMainLoop object by one.
g_main_loop_unref ()void g_main_loop_unref (GMainLoop *loop); Decreases the reference count on a GMainLoop object by one. If the result is zero, free the loop and free all associated memory.
g_main_loop_run ()void g_main_loop_run (GMainLoop *loop);
Runs a main loop until
g_main_loop_quit ()void g_main_loop_quit (GMainLoop *loop);
Stops a GMainLoop from running. Any calls to
g_main_loop_is_running ()gboolean g_main_loop_is_running (GMainLoop *loop);
Checks to see if the main loop is currently being run via
g_main_loop_get_context ()GMainContext* g_main_loop_get_context (GMainLoop *loop);
Returns the GMainContext of
g_main_new()#define g_main_new(is_running) Warning
Creates a new GMainLoop for the default main loop.
g_main_destroy()#define g_main_destroy(loop) Warning
Frees the memory allocated for the GMainLoop.
g_main_run()#define g_main_run(loop) Warning
Runs a main loop until it stops running.
g_main_quit()#define g_main_quit(loop) Warning
Stops the GMainLoop. If
g_main_is_running()#define g_main_is_running(loop) Warning
Checks if the main loop is running.
G_PRIORITY_HIGH#define G_PRIORITY_HIGH -100 Use this for high priority event sources. It is not used within GLib or GTK+. G_PRIORITY_DEFAULT#define G_PRIORITY_DEFAULT 0
Use this for default priority event sources.
In GLib this priority is used when adding timeout functions with
G_PRIORITY_HIGH_IDLE#define G_PRIORITY_HIGH_IDLE 100 Use this for high priority idle functions. GTK+ uses G_PRIORITY_HIGH_IDLE + 10 for resizing operations, and G_PRIORITY_HIGH_IDLE + 20 for redrawing operations. (This is done to ensure that any pending resizes are processed before any pending redraws, so that widgets are not redrawn twice unnecessarily.) G_PRIORITY_DEFAULT_IDLE#define G_PRIORITY_DEFAULT_IDLE 200
Use this for default priority idle functions.
In GLib this priority is used when adding idle functions with G_PRIORITY_LOW#define G_PRIORITY_LOW 300 Use this for very low priority background tasks. It is not used within GLib or GTK+. GMainContexttypedef struct _GMainContext GMainContext; The GMainContext struct is an opaque data type representing a set of sources to be handled in a main loop. g_main_context_new ()GMainContext* g_main_context_new (void); Creates a new GMainContext strcuture
g_main_context_ref ()GMainContext* g_main_context_ref (GMainContext *context); Increases the reference count on a GMainContext object by one.
g_main_context_unref ()void g_main_context_unref (GMainContext *context); Decreases the reference count on a GMainContext object by one. If the result is zero, free the context and free all associated memory.
g_main_context_default ()GMainContext* g_main_context_default (void); Returns the default main context. This is the main context used for main loop functions when a main loop is not explicitly specified.
g_main_context_iteration ()gboolean g_main_context_iteration (GMainContext *context, gboolean may_block);
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
g_main_iteration()#define g_main_iteration(may_block) Warning
Runs a single iteration for the default GMainContext.
g_main_context_pending ()gboolean g_main_context_pending (GMainContext *context); Checks if any sources have pending events for the given context.
g_main_pending()#define g_main_pending() Warning
Checks if any events are pending for the default GMainContext (i.e. ready to be processed).
g_main_context_find_source_by_id ()GSource* g_main_context_find_source_by_id (GMainContext *context, guint source_id); Finds a GSource given a pair of context and ID
g_main_context_find_source_by_user_data ()GSource* g_main_context_find_source_by_user_data (GMainContext *context, gpointer user_data); 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.
g_main_context_find_source_by_funcs_user_data ()GSource* g_main_context_find_source_by_funcs_user_data (GMainContext *context, GSourceFuncs *funcs, gpointer user_data); 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.
g_main_context_wakeup ()void g_main_context_wakeup (GMainContext *context);
If
g_main_context_acquire ()gboolean g_main_context_acquire (GMainContext *context);
Tries to become the owner of the specified context.
If some other context is the owner of the context,
returns
You must be the owner of a context before you
can call
g_main_context_release ()void g_main_context_release (GMainContext *context);
Releases ownership of a context previously acquired by this thread
with
g_main_context_wait ()gboolean g_main_context_wait (GMainContext *context, GCond *cond, GMutex *mutex);
Tries to become the owner of the specified context,
as with
g_main_context_prepare ()gboolean g_main_context_prepare (GMainContext *context, gint *priority);
Prepares to poll sources within a main loop. The resulting information
for polling is determined by calling
g_main_context_query ()gint g_main_context_query (GMainContext *context, gint max_priority, gint *timeout_, GPollFD *fds, gint n_fds); Determines information necessary to poll this main loop.
g_main_context_check ()gint g_main_context_check (GMainContext *context, gint max_priority, GPollFD *fds, gint n_fds); Passes the results of polling back to the main loop.
g_main_context_dispatch ()void g_main_context_dispatch (GMainContext *context); Dispatches all pending sources.
g_main_context_set_poll_func ()void g_main_context_set_poll_func (GMainContext *context, GPollFunc func);
Sets the function to use to handle polling of file descriptors. It
will be used instead of the This function could possibly be used to integrate the GLib event loop with an external event loop.
g_main_context_get_poll_func ()GPollFunc g_main_context_get_poll_func (GMainContext *context);
Gets the poll function set by
GPollFunc ()gint (*GPollFunc) (GPollFD *ufds, guint nfsd, gint timeout_);
Specifies the type of function passed to
g_main_context_add_poll ()void g_main_context_add_poll (GMainContext *context, GPollFD *fd, gint priority);
Adds a file descriptor to the set of file descriptors polled for
this context. This will very seldomly be used directly. Instead
a typical event source will use
g_main_context_remove_poll ()void g_main_context_remove_poll (GMainContext *context, GPollFD *fd); Removes file descriptor from the set of file descriptors to be polled for a particular context.
g_main_depth ()int g_main_depth (void); Return value: The main loop recursion level in the current thread
g_main_set_poll_func()#define g_main_set_poll_func(func) Warning
Sets the function to use for the handle polling of file descriptors for the default main context.
g_timeout_source_new ()GSource* g_timeout_source_new (guint interval); Creates a new timeout source.
The source will not initially be associated with any GMainContext
and must be added to one with
g_timeout_add ()guint g_timeout_add (guint interval, GSourceFunc function, gpointer data);
Sets a function to be called at regular intervals, with the default
priority, G_PRIORITY_DEFAULT. The function is called repeatedly
until it returns Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval (it does not try to 'catch up' time lost in delays).
g_timeout_add_full ()guint g_timeout_add_full (gint priority, guint interval, GSourceFunc function, gpointer data, GDestroyNotify notify);
Sets a function to be called at regular intervals, with the given
priority. The function is called repeatedly until it returns
Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval (it does not try to 'catch up' time lost in delays).
g_idle_source_new ()GSource* g_idle_source_new (void); Creates a new idle source.
The source will not initially be associated with any GMainContext
and must be added to one with
g_idle_add ()guint g_idle_add (GSourceFunc function, gpointer data);
Adds a function to be called whenever there are no higher priority
events pending to the default main loop. The function is given the
default idle priority, G_PRIORITY_DEFAULT_IDLE. If the function
returns
g_idle_add_full ()guint g_idle_add_full (gint priority, GSourceFunc function, gpointer data, GDestroyNotify notify);
Adds a function to be called whenever there are no higher priority
events pending. If the function returns
g_idle_remove_by_data ()gboolean g_idle_remove_by_data (gpointer data); Removes the idle function with the given data.
GPidtypedef int GPid; A type which is used to hold a process identification. On Unix, processes are identified by a process id (an integer), while Windows uses process handles (which are pointers). GChildWatchFunc ()void (*GChildWatchFunc) (GPid pid, gint status, gpointer data); The type of functions to be called when a child exists.
g_child_watch_source_new ()GSource* g_child_watch_source_new (GPid pid); Creates a new child_watch source.
The source will not initially be associated with any GMainContext
and must be added to one with
Note that on platforms where GPid must be explicitely closed
(see
Note further that using
Since 2.4 g_child_watch_add ()guint g_child_watch_add (GPid pid, GChildWatchFunc function, gpointer data);
Sets a function to be called when the child indicated by
Note that on platforms where GPid must be explicitely closed
(see GLib supports only a single callback per process id.
Since 2.4 g_child_watch_add_full ()guint g_child_watch_add_full (gint priority, GPid pid, GChildWatchFunc function, gpointer data, GDestroyNotify notify);
Sets a function to be called when the child indicated by
Note that on platforms where GPid must be explicitely closed
(see GLib supports only a single callback per process id.
Since 2.4 GPollFDtypedef struct { gint fd; gushort events; gushort revents; } GPollFD;
GSourcetypedef struct { } GSource; The GSource struct is an opaque data type representing an event source. GSourceDummyMarshal ()void (*GSourceDummyMarshal) (void); This is just a placeholder for GClosureMarshal, which cannot be used here for dependency reasons. GSourceFuncstypedef struct { gboolean (*prepare) (GSource *source, gint *timeout_); gboolean (*check) (GSource *source); gboolean (*dispatch) (GSource *source, GSourceFunc callback, gpointer user_data); void (*finalize) (GSource *source); /* Can be NULL */ /* For use by g_source_set_closure */ GSourceFunc closure_callback; GSourceDummyMarshal closure_marshal; /* Really is of type GClosureMarshal */ } GSourceFuncs; The GSourceFuncs struct contains a table of functions used to handle event sources in a generic manner.
For idle sources, the prepare and check functions always return
For timeout sources, the prepare and check functions both return
For file descriptor sources, the prepare function typically returns GSourceCallbackFuncstypedef struct { void (*ref) (gpointer cb_data); void (*unref) (gpointer cb_data); void (*get) (gpointer cb_data, GSource *source, GSourceFunc *func, gpointer *data); } GSourceCallbackFuncs; The GSourceCallbackFuncs struct contains functions for managing callback objects.
g_source_new ()GSource* g_source_new (GSourceFuncs *source_funcs, guint struct_size);
Creates a new GSource structure. The size is specified to
allow creating structures derived from GSource that contain
additional data. The size passed in must be at least
The source will not initially be associated with any GMainContext
and must be added to one with
g_source_ref ()GSource* g_source_ref (GSource *source); Increases the reference count on a source by one.
g_source_unref ()void g_source_unref (GSource *source); Decreases the reference count of a source by one. If the resulting reference count is zero the source and associated memory will be destroyed.
g_source_attach ()guint g_source_attach (GSource *source, GMainContext *context);
Adds a GSource to a
g_source_destroy ()void g_source_destroy (GSource *source); Removes a source from its GMainContext, if any, and mark it as destroyed. The source cannot be subsequently added to another context.
g_source_set_priority ()void g_source_set_priority (GSource *source, gint priority); 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.
g_source_get_priority ()gint g_source_get_priority (GSource *source); Gets the priority of a source.
g_source_set_can_recurse ()void g_source_set_can_recurse (GSource *source, gboolean can_recurse);
Sets whether a source can be called recursively. If
g_source_get_can_recurse ()gboolean g_source_get_can_recurse (GSource *source);
Checks whether a source is allowed to be called recursively.
see
g_source_get_id ()guint g_source_get_id (GSource *source);
Returns the numeric ID for a particular source. The ID of a source
is unique within a particular main loop context. The reverse
mapping from ID to source is done by
g_source_get_context ()GMainContext* g_source_get_context (GSource *source); Gets the GMainContext with which the source is associated. Calling this function on a destroyed source is an error.
g_source_set_callback ()void g_source_set_callback (GSource *source, GSourceFunc func, gpointer data, GDestroyNotify notify); Sets the callback function for a source. The callback for a source is called from the source's dispatch function.
The exact type of Typically, you won't use this function. Instead use functions specific to the type of source you are using.
GSourceFunc ()gboolean (*GSourceFunc) (gpointer data);
Specifies the type of function passed to
g_source_set_callback_indirect ()void g_source_set_callback_indirect (GSource *source, gpointer callback_data, GSourceCallbackFuncs *callback_funcs);
Sets the callback function storing the data as a refcounted callback
"object". This is used internally. Note that calling
g_source_add_poll ()void g_source_add_poll (GSource *source, GPollFD *fd);
Adds a file descriptor to the set of file descriptors polled for
this source. This is usually combined with
g_source_remove_poll ()void g_source_remove_poll (GSource *source, GPollFD *fd); Removes a file descriptor from the set of file descriptors polled for this source.
g_source_get_current_time ()void g_source_get_current_time (GSource *source, GTimeVal *timeval);
Gets the "current time" to be used when checking
this source. The advantage of calling this function over
calling
g_source_remove ()gboolean g_source_remove (guint tag);
Removes the source with the given id from the default main context. The id of
a GSource is given by
See also
g_source_remove_by_funcs_user_data ()gboolean g_source_remove_by_funcs_user_data (GSourceFuncs *funcs, gpointer user_data); Removes a source from the default main loop context given the source functions and user data. If multiple sources exist with the same source functions and user data, only one will be destroyed.
g_source_remove_by_user_data ()gboolean g_source_remove_by_user_data (gpointer user_data); Removes a source from the default main loop context given the user data for the callback. If multiple sources exist with the same user data, only one will be destroyed.
|
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0048 ]-- |