| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>The Main Event Loop: GLib Reference Manual</title> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> |
| <link rel="home" href="index.html" title="GLib Reference Manual"> |
| <link rel="up" href="glib-core.html" title="GLib Core Application Support"> |
| <link rel="prev" href="glib-core.html" title="GLib Core Application Support"> |
| <link rel="next" href="glib-Threads.html" title="Threads"> |
| <meta name="generator" content="GTK-Doc V1.25.1 (XML mode)"> |
| <link rel="stylesheet" href="style.css" type="text/css"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle"> |
| <td width="100%" align="left" class="shortcuts"> |
| <a href="#" class="shortcut">Top</a><span id="nav_description"> <span class="dim">|</span> |
| <a href="#glib-The-Main-Event-Loop.description" class="shortcut">Description</a></span> |
| </td> |
| <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> |
| <td><a accesskey="u" href="glib-core.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> |
| <td><a accesskey="p" href="glib-core.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> |
| <td><a accesskey="n" href="glib-Threads.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td> |
| </tr></table> |
| <div class="refentry"> |
| <a name="glib-The-Main-Event-Loop"></a><div class="titlepage"></div> |
| <div class="refnamediv"><table width="100%"><tr> |
| <td valign="top"> |
| <h2><span class="refentrytitle"><a name="glib-The-Main-Event-Loop.top_of_page"></a>The Main Event Loop</span></h2> |
| <p>The Main Event Loop — manages all available sources of events</p> |
| </td> |
| <td class="gallery_image" valign="top" align="right"></td> |
| </tr></table></div> |
| <div class="refsect1"> |
| <a name="glib-The-Main-Event-Loop.functions"></a><h2>Functions</h2> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="functions_return"> |
| <col class="functions_name"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="returnvalue">GMainLoop</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-new" title="g_main_loop_new ()">g_main_loop_new</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="returnvalue">GMainLoop</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-ref" title="g_main_loop_ref ()">g_main_loop_ref</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-unref" title="g_main_loop_unref ()">g_main_loop_unref</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()">g_main_loop_run</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()">g_main_loop_quit</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-is-running" title="g_main_loop_is_running ()">g_main_loop_is_running</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-get-context" title="g_main_loop_get_context ()">g_main_loop_get_context</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-new" title="g_main_new()">g_main_new</a><span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-destroy" title="g_main_destroy()">g_main_destroy</a><span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-run" title="g_main_run()">g_main_run</a><span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-quit" title="g_main_quit()">g_main_quit</a><span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-is-running" title="g_main_is_running()">g_main_is_running</a><span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-new" title="g_main_context_new ()">g_main_context_new</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref" title="g_main_context_ref ()">g_main_context_ref</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-unref" title="g_main_context_unref ()">g_main_context_unref</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-default" title="g_main_context_default ()">g_main_context_default</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()">g_main_context_iteration</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-iteration" title="g_main_iteration()">g_main_iteration</a><span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pending" title="g_main_context_pending ()">g_main_context_pending</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#g-main-pending" title="g_main_pending">g_main_pending</a></td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-find-source-by-id" title="g_main_context_find_source_by_id ()">g_main_context_find_source_by_id</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-find-source-by-user-data" title="g_main_context_find_source_by_user_data ()">g_main_context_find_source_by_user_data</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-find-source-by-funcs-user-data" title="g_main_context_find_source_by_funcs_user_data ()">g_main_context_find_source_by_funcs_user_data</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-wakeup" title="g_main_context_wakeup ()">g_main_context_wakeup</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()">g_main_context_acquire</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-release" title="g_main_context_release ()">g_main_context_release</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-is-owner" title="g_main_context_is_owner ()">g_main_context_is_owner</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-wait" title="g_main_context_wait ()">g_main_context_wait</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-prepare" title="g_main_context_prepare ()">g_main_context_prepare</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()">g_main_context_query</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-check" title="g_main_context_check ()">g_main_context_check</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-dispatch" title="g_main_context_dispatch ()">g_main_context_dispatch</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-set-poll-func" title="g_main_context_set_poll_func ()">g_main_context_set_poll_func</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GPollFunc" title="GPollFunc ()"><span class="returnvalue">GPollFunc</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-poll-func" title="g_main_context_get_poll_func ()">g_main_context_get_poll_func</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| </td> |
| <td class="function_name"> |
| <span class="c_punctuation">(</span><a class="link" href="glib-The-Main-Event-Loop.html#GPollFunc" title="GPollFunc ()">*GPollFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-add-poll" title="g_main_context_add_poll ()">g_main_context_add_poll</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-remove-poll" title="g_main_context_remove_poll ()">g_main_context_remove_poll</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-depth" title="g_main_depth ()">g_main_depth</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-current-source" title="g_main_current_source ()">g_main_current_source</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-set-poll-func" title="g_main_set_poll_func()">g_main_set_poll_func</a><span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-invoke" title="g_main_context_invoke ()">g_main_context_invoke</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-invoke-full" title="g_main_context_invoke_full ()">g_main_context_invoke_full</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()">g_main_context_get_thread_default</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref-thread-default" title="g_main_context_ref_thread_default ()">g_main_context_ref_thread_default</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-push-thread-default" title="g_main_context_push_thread_default ()">g_main_context_push_thread_default</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pop-thread-default" title="g_main_context_pop_thread_default ()">g_main_context_pop_thread_default</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new" title="g_timeout_source_new ()">g_timeout_source_new</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new-seconds" title="g_timeout_source_new_seconds ()">g_timeout_source_new_seconds</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()">g_timeout_add</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-full" title="g_timeout_add_full ()">g_timeout_add_full</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds" title="g_timeout_add_seconds ()">g_timeout_add_seconds</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds-full" title="g_timeout_add_seconds_full ()">g_timeout_add_seconds_full</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-source-new" title="g_idle_source_new ()">g_idle_source_new</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()">g_idle_add</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add-full" title="g_idle_add_full ()">g_idle_add_full</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-remove-by-data" title="g_idle_remove_by_data ()">g_idle_remove_by_data</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <span class="c_punctuation">(</span><a class="link" href="glib-The-Main-Event-Loop.html#GChildWatchFunc" title="GChildWatchFunc ()">*GChildWatchFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-source-new" title="g_child_watch_source_new ()">g_child_watch_source_new</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add" title="g_child_watch_add ()">g_child_watch_add</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add-full" title="g_child_watch_add_full ()">g_child_watch_add_full</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-poll" title="g_poll ()">g_poll</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <span class="c_punctuation">(</span><a class="link" href="glib-The-Main-Event-Loop.html#GSourceDummyMarshal" title="GSourceDummyMarshal ()">*GSourceDummyMarshal</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()">g_source_new</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-ref" title="g_source_ref ()">g_source_ref</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-unref" title="g_source_unref ()">g_source_unref</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-funcs" title="g_source_set_funcs ()">g_source_set_funcs</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()">g_source_attach</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-destroy" title="g_source_destroy ()">g_source_destroy</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-is-destroyed" title="g_source_is_destroyed ()">g_source_is_destroyed</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-priority" title="g_source_set_priority ()">g_source_set_priority</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-priority" title="g_source_get_priority ()">g_source_get_priority</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-can-recurse" title="g_source_set_can_recurse ()">g_source_set_can_recurse</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-can-recurse" title="g_source_get_can_recurse ()">g_source_get_can_recurse</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-id" title="g_source_get_id ()">g_source_get_id</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type">const <span class="returnvalue">char</span> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-name" title="g_source_get_name ()">g_source_get_name</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-name" title="g_source_set_name ()">g_source_set_name</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-name-by-id" title="g_source_set_name_by_id ()">g_source_set_name_by_id</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-context" title="g_source_get_context ()">g_source_get_context</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-callback" title="g_source_set_callback ()">g_source_set_callback</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <span class="c_punctuation">(</span><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()">*GSourceFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-callback-indirect" title="g_source_set_callback_indirect ()">g_source_set_callback_indirect</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-ready-time" title="g_source_set_ready_time ()">g_source_set_ready_time</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="returnvalue">gint64</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-ready-time" title="g_source_get_ready_time ()">g_source_get_ready_time</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-unix-fd" title="g_source_add_unix_fd ()">g_source_add_unix_fd</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-unix-fd" title="g_source_remove_unix_fd ()">g_source_remove_unix_fd</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-modify-unix-fd" title="g_source_modify_unix_fd ()">g_source_modify_unix_fd</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-IO-Channels.html#GIOCondition" title="enum GIOCondition"><span class="returnvalue">GIOCondition</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-query-unix-fd" title="g_source_query_unix_fd ()">g_source_query_unix_fd</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-poll" title="g_source_add_poll ()">g_source_add_poll</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-poll" title="g_source_remove_poll ()">g_source_remove_poll</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-child-source" title="g_source_add_child_source ()">g_source_add_child_source</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-child-source" title="g_source_remove_child_source ()">g_source_remove_child_source</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="returnvalue">gint64</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-time" title="g_source_get_time ()">g_source_get_time</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-current-time" title="g_source_get_current_time ()">g_source_get_current_time</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove" title="g_source_remove ()">g_source_remove</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-by-funcs-user-data" title="g_source_remove_by_funcs_user_data ()">g_source_remove_by_funcs_user_data</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-by-user-data" title="g_source_remove_by_user_data ()">g_source_remove_by_user_data</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect1"> |
| <a name="glib-The-Main-Event-Loop.other"></a><h2>Types and Values</h2> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="name"> |
| <col class="description"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="datatype_keyword"> </td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop">GMainLoop</a></td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH:CAPS" title="G_PRIORITY_HIGH">G_PRIORITY_HIGH</a></td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT">G_PRIORITY_DEFAULT</a></td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE">G_PRIORITY_HIGH_IDLE</a></td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE">G_PRIORITY_DEFAULT_IDLE</a></td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-LOW:CAPS" title="G_PRIORITY_LOW">G_PRIORITY_LOW</a></td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#G-SOURCE-CONTINUE:CAPS" title="G_SOURCE_CONTINUE">G_SOURCE_CONTINUE</a></td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#G-SOURCE-REMOVE:CAPS" title="G_SOURCE_REMOVE">G_SOURCE_REMOVE</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword"> </td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext">GMainContext</a></td> |
| </tr> |
| <tr> |
| <td class="typedef_keyword">typedef</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid">GPid</a></td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#G-PID-FORMAT:CAPS" title="G_PID_FORMAT">G_PID_FORMAT</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">struct</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD">GPollFD</a></td> |
| </tr> |
| <tr> |
| <td class="define_keyword">#define</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#G-POLLFD-FORMAT:CAPS" title="G_POLLFD_FORMAT">G_POLLFD_FORMAT</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">struct</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource">GSource</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">struct</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs">GSourceFuncs</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">struct</td> |
| <td class="function_name"><a class="link" href="glib-The-Main-Event-Loop.html#GSourceCallbackFuncs" title="struct GSourceCallbackFuncs">GSourceCallbackFuncs</a></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect1"> |
| <a name="glib-The-Main-Event-Loop.includes"></a><h2>Includes</h2> |
| <pre class="synopsis">#include <glib.h> |
| </pre> |
| </div> |
| <div class="refsect1"> |
| <a name="glib-The-Main-Event-Loop.description"></a><h2>Description</h2> |
| <p>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 <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>.</p> |
| <p>To allow multiple independent sets of sources to be handled in |
| different threads, each source is associated with a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>. |
| A GMainContext can only be running in a single thread, but |
| sources can be added to it and removed from it from other threads.</p> |
| <p>Each event source is assigned a priority. The default priority, |
| <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a>, 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.</p> |
| <p>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.</p> |
| <p>The <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> data type represents a main event loop. A GMainLoop is |
| created with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-new" title="g_main_loop_new ()"><code class="function">g_main_loop_new()</code></a>. After adding the initial event sources, |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a> is called. This continuously checks for new events from |
| each of the event sources and dispatches them. Finally, the processing of |
| an event from one of the sources leads to a call to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()"><code class="function">g_main_loop_quit()</code></a> to |
| exit the main loop, and <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a> returns.</p> |
| <p>It is possible to create new instances of <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> recursively. |
| This is often used in GTK+ applications when showing modal dialog |
| boxes. Note that event sources are associated with a particular |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, and will be checked and dispatched for all main |
| loops associated with that GMainContext.</p> |
| <p>GTK+ contains wrappers of some of these functions, e.g. <a href="http://developer.gnome.org/gtk3/gtk3-General.html#gtk-main"><code class="function">gtk_main()</code></a>, |
| <a href="http://developer.gnome.org/gtk3/gtk3-General.html#gtk-main-quit"><code class="function">gtk_main_quit()</code></a> and <a href="http://developer.gnome.org/gtk3/gtk3-General.html#gtk-events-pending"><code class="function">gtk_events_pending()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="id-1.4.2.6.9"></a><h4>Creating new source types</h4> |
| <p>One of the unusual features of the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> 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 <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> structure. The derived type of |
| source is represented by a structure that has the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> structure |
| as a first element, and other elements specific to the new source |
| type. To create an instance of the new source type, call |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()"><code class="function">g_source_new()</code></a> passing in the size of the derived structure and |
| a table of functions. These <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> determine the behavior of |
| the new source type.</p> |
| <p>New source types basically interact with the main context |
| in two ways. Their prepare function in <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> 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 |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-poll" title="g_source_add_poll ()"><code class="function">g_source_add_poll()</code></a>.</p> |
| </div> |
| <div class="refsect3"> |
| <a name="id-1.4.2.6.10"></a><h4>Customizing the main loop iteration</h4> |
| <p>Single iterations of a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> can be run with |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a>. In some cases, more detailed control |
| of exactly how the details of the main loop work is desired, for |
| instance, when integrating the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> with an external main loop. |
| In such cases, you can call the component functions of |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a> directly. These functions are |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-prepare" title="g_main_context_prepare ()"><code class="function">g_main_context_prepare()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a>, |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-check" title="g_main_context_check ()"><code class="function">g_main_context_check()</code></a> and <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-dispatch" title="g_main_context_dispatch ()"><code class="function">g_main_context_dispatch()</code></a>.</p> |
| </div> |
| <div class="refsect3"> |
| <a name="mainloop-states"></a><h4>State of a Main Context</h4> |
| <p>The operation of these functions can best be seen in terms |
| of a state diagram, as shown in this image.</p> |
| <p><span class="inlinemediaobject"><img src="mainloop-states.gif"></span></p> |
| <p>On UNIX, the GLib mainloop is incompatible with <code class="function">fork()</code>. Any program |
| using the mainloop must either <code class="function">exec()</code> or <code class="function">exit()</code> from the child |
| without returning to the mainloop.</p> |
| </div> |
| <div class="refsect3"> |
| <a name="mainloop-memory-management"></a><h4>Memory management of sources</h4> |
| <p>There are two options for memory management of the user data passed to a |
| <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> to be passed to its callback on invocation. This data is provided |
| in calls to <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-full" title="g_timeout_add_full ()"><code class="function">g_timeout_add_full()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>, etc. and |
| more generally, using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-callback" title="g_source_set_callback ()"><code class="function">g_source_set_callback()</code></a>. This data is typically an |
| object which ‘owns’ the timeout or idle callback, such as a widget or a |
| network protocol implementation. In many cases, it is an error for the |
| callback to be invoked after this owning object has been destroyed, as that |
| results in use of freed memory.</p> |
| <p>The first, and preferred, option is to store the source ID returned by |
| functions such as <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a> or <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>, and explicitly |
| remove that source from the main context using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove" title="g_source_remove ()"><code class="function">g_source_remove()</code></a> when the |
| owning object is finalized. This ensures that the callback can only be |
| invoked while the object is still alive.</p> |
| <p>The second option is to hold a strong reference to the object in the |
| callback, and to release it in the callback’s <a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a>. This ensures |
| that the object is kept alive until after the source is finalized, which is |
| guaranteed to be after it is invoked for the final time. The <a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> |
| is another callback passed to the ‘full’ variants of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> functions (for |
| example, <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-full" title="g_timeout_add_full ()"><code class="function">g_timeout_add_full()</code></a>). It is called when the source is finalized, |
| and is designed for releasing references like this.</p> |
| <p>One important caveat of this second approach is that it will keep the object |
| alive indefinitely if the main loop is stopped before the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> is |
| invoked, which may be undesirable.</p> |
| </div> |
| </div> |
| <div class="refsect1"> |
| <a name="glib-The-Main-Event-Loop.functions_details"></a><h2>Functions</h2> |
| <div class="refsect2"> |
| <a name="g-main-loop-new"></a><h3>g_main_loop_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="returnvalue">GMainLoop</span></a> * |
| g_main_loop_new (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> is_running</code></em>);</pre> |
| <p>Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> structure.</p> |
| <div class="refsect3"> |
| <a name="g-main-loop-new.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>is_running</p></td> |
| <td class="parameter_description"><p>set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> to indicate that the loop is running. This |
| is not very important since calling <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a> will set this to |
| <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> anyway.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-loop-new.returns"></a><h4>Returns</h4> |
| <p> a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-loop-ref"></a><h3>g_main_loop_ref ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="returnvalue">GMainLoop</span></a> * |
| g_main_loop_ref (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre> |
| <p>Increases the reference count on a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> object by one.</p> |
| <div class="refsect3"> |
| <a name="g-main-loop-ref.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-loop-ref.returns"></a><h4>Returns</h4> |
| <p> <em class="parameter"><code>loop</code></em> |
| </p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-loop-unref"></a><h3>g_main_loop_unref ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_loop_unref (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre> |
| <p>Decreases the reference count on a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> object by one. If |
| the result is zero, free the loop and free all associated memory.</p> |
| <div class="refsect3"> |
| <a name="g-main-loop-unref.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-loop-run"></a><h3>g_main_loop_run ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_loop_run (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre> |
| <p>Runs a main loop until <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()"><code class="function">g_main_loop_quit()</code></a> is called on the loop. |
| If this is called for the thread of the loop's <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, |
| it will process events from the loop, otherwise it will |
| simply wait.</p> |
| <div class="refsect3"> |
| <a name="g-main-loop-run.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-loop-quit"></a><h3>g_main_loop_quit ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_loop_quit (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre> |
| <p>Stops a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> from running. Any calls to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a> |
| for the loop will return. </p> |
| <p>Note that sources that have already been dispatched when |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()"><code class="function">g_main_loop_quit()</code></a> is called will still be executed.</p> |
| <div class="refsect3"> |
| <a name="g-main-loop-quit.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-loop-is-running"></a><h3>g_main_loop_is_running ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_main_loop_is_running (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre> |
| <p>Checks to see if the main loop is currently being run via <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-main-loop-is-running.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-loop-is-running.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the mainloop is currently being run.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-loop-get-context"></a><h3>g_main_loop_get_context ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| g_main_loop_get_context (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> *loop</code></em>);</pre> |
| <p>Returns the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> of <em class="parameter"><code>loop</code></em> |
| .</p> |
| <div class="refsect3"> |
| <a name="g-main-loop-get-context.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-loop-get-context.returns"></a><h4>Returns</h4> |
| <p> the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> of <em class="parameter"><code>loop</code></em> |
| . </p> |
| <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-new"></a><h3>g_main_new()</h3> |
| <pre class="programlisting">#define g_main_new(is_running)</pre> |
| <div class="warning"> |
| <p><code class="literal">g_main_new</code> has been deprecated since version 2.2 and should not be used in newly-written code.</p> |
| <p>Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-new" title="g_main_loop_new ()"><code class="function">g_main_loop_new()</code></a> instead</p> |
| </div> |
| <p>Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> for th default main context.</p> |
| <div class="refsect3"> |
| <a name="g-main-new.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>is_running</p></td> |
| <td class="parameter_description"><p>set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> to indicate that the loop is running. This |
| is not very important since calling <a class="link" href="glib-The-Main-Event-Loop.html#g-main-run" title="g_main_run()"><code class="function">g_main_run()</code></a> will set this |
| to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> anyway.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-new.returns"></a><h4>Returns</h4> |
| <p> a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a></p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-destroy"></a><h3>g_main_destroy()</h3> |
| <pre class="programlisting">#define g_main_destroy(loop)</pre> |
| <div class="warning"> |
| <p><code class="literal">g_main_destroy</code> has been deprecated since version 2.2 and should not be used in newly-written code.</p> |
| <p>Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-unref" title="g_main_loop_unref ()"><code class="function">g_main_loop_unref()</code></a> instead</p> |
| </div> |
| <p>Frees the memory allocated for the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.</p> |
| <div class="refsect3"> |
| <a name="g-main-destroy.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-run"></a><h3>g_main_run()</h3> |
| <pre class="programlisting">#define g_main_run(loop)</pre> |
| <div class="warning"> |
| <p><code class="literal">g_main_run</code> has been deprecated since version 2.2 and should not be used in newly-written code.</p> |
| <p>Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a> instead</p> |
| </div> |
| <p>Runs a main loop until it stops running.</p> |
| <div class="refsect3"> |
| <a name="g-main-run.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-quit"></a><h3>g_main_quit()</h3> |
| <pre class="programlisting">#define g_main_quit(loop)</pre> |
| <div class="warning"> |
| <p><code class="literal">g_main_quit</code> has been deprecated since version 2.2 and should not be used in newly-written code.</p> |
| <p>Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-quit" title="g_main_loop_quit ()"><code class="function">g_main_loop_quit()</code></a> instead</p> |
| </div> |
| <p>Stops the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>. |
| If <a class="link" href="glib-The-Main-Event-Loop.html#g-main-run" title="g_main_run()"><code class="function">g_main_run()</code></a> was called to run the <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>, it will now return.</p> |
| <div class="refsect3"> |
| <a name="g-main-quit.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-is-running"></a><h3>g_main_is_running()</h3> |
| <pre class="programlisting">#define g_main_is_running(loop)</pre> |
| <div class="warning"> |
| <p><code class="literal">g_main_is_running</code> has been deprecated since version 2.2 and should not be used in newly-written code.</p> |
| <p>Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-is-running" title="g_main_loop_is_running ()"><code class="function">g_main_loop_is_running()</code></a> instead</p> |
| </div> |
| <p>Checks if the main loop is running.</p> |
| <div class="refsect3"> |
| <a name="g-main-is-running.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>loop</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-is-running.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the main loop is running</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-new"></a><h3>g_main_context_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| g_main_context_new (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p>Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> structure.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-new.returns"></a><h4>Returns</h4> |
| <p> the new <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-ref"></a><h3>g_main_context_ref ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| g_main_context_ref (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Increases the reference count on a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> object by one.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-ref.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-ref.returns"></a><h4>Returns</h4> |
| <p> the <em class="parameter"><code>context</code></em> |
| that was passed in (since 2.6)</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-unref"></a><h3>g_main_context_unref ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_unref (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Decreases the reference count on a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> object by one. If |
| the result is zero, free the context and free all associated memory.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-unref.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-default"></a><h3>g_main_context_default ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| g_main_context_default (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p>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 |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()"><code class="function">g_main_context_get_thread_default()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-default.returns"></a><h4>Returns</h4> |
| <p> the global default main context. </p> |
| <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-iteration"></a><h3>g_main_context_iteration ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_main_context_iteration (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> may_block</code></em>);</pre> |
| <p>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 <em class="parameter"><code>may_block</code></em> |
| is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, waiting |
| for a source to become ready, then dispatching the highest priority |
| events sources that are ready. Otherwise, if <em class="parameter"><code>may_block</code></em> |
| is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> |
| 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.</p> |
| <p>Note that even when <em class="parameter"><code>may_block</code></em> |
| is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, it is still possible for |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a> to return <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, since the wait may |
| be interrupted for other reasons than an event source becoming ready.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-iteration.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>may_block</p></td> |
| <td class="parameter_description"><p>whether the call may block.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-iteration.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if events were dispatched.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-iteration"></a><h3>g_main_iteration()</h3> |
| <pre class="programlisting">#define g_main_iteration(may_block)</pre> |
| <div class="warning"> |
| <p><code class="literal">g_main_iteration</code> has been deprecated since version 2.2 and should not be used in newly-written code.</p> |
| <p>Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a> instead.</p> |
| </div> |
| <p>Runs a single iteration for the default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>.</p> |
| <div class="refsect3"> |
| <a name="g-main-iteration.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>may_block</p></td> |
| <td class="parameter_description"><p>set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if it should block (i.e. wait) until an event |
| source becomes ready. It will return after an event source has been |
| processed. If set to <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> it will return immediately if no event |
| source is ready to be processed.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-iteration.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if more events are pending.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-pending"></a><h3>g_main_context_pending ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_main_context_pending (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Checks if any sources have pending events for the given context.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-pending.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-pending.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if events are pending.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-pending"></a><h3>g_main_pending</h3> |
| <pre class="programlisting">#define g_main_pending()</pre> |
| <div class="warning"><p><code class="literal">g_main_pending</code> is deprecated and should not be used in newly-written code.</p></div> |
| <p>Checks if any events are pending for the default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| (i.e. ready to be processed).</p> |
| <div class="refsect3"> |
| <a name="g-main-pending.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if any events are pending.</p> |
| <p>Deprected: 2.2: Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pending" title="g_main_context_pending ()"><code class="function">g_main_context_pending()</code></a> instead.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-find-source-by-id"></a><h3>g_main_context_find_source_by_id ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_main_context_find_source_by_id (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> source_id</code></em>);</pre> |
| <p>Finds a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> given a pair of context and ID.</p> |
| <p>It is a programmer error to attempt to lookup a non-existent source.</p> |
| <p>More specifically: source IDs can be reissued after a source has been |
| destroyed and therefore it is never valid to use this function with a |
| source ID which may have already been removed. An example is when |
| scheduling an idle to run in another thread with <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>: the |
| idle may already have run and been removed by the time this function |
| is called on its (now invalid) source ID. This source ID may have |
| been reissued, leading to the operation being performed against the |
| wrong source.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-find-source-by-id.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>source_id</p></td> |
| <td class="parameter_description"><p>the source ID, as returned by <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-id" title="g_source_get_id ()"><code class="function">g_source_get_id()</code></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-find-source-by-id.returns"></a><h4>Returns</h4> |
| <p> the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. </p> |
| <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-find-source-by-user-data"></a><h3>g_main_context_find_source_by_user_data ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_main_context_find_source_by_user_data |
| (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre> |
| <p>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.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-find-source-by-user-data.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>user_data</p></td> |
| <td class="parameter_description"><p>the user_data for the callback.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-find-source-by-user-data.returns"></a><h4>Returns</h4> |
| <p> the source, if one was found, otherwise <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p> |
| <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-find-source-by-funcs-user-data"></a><h3>g_main_context_find_source_by_funcs_user_data ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_main_context_find_source_by_funcs_user_data |
| (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre> |
| <p>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.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-find-source-by-funcs-user-data.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>funcs</p></td> |
| <td class="parameter_description"><p>the <em class="parameter"><code>source_funcs</code></em> |
| passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()"><code class="function">g_source_new()</code></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>user_data</p></td> |
| <td class="parameter_description"><p>the user data from the callback.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-find-source-by-funcs-user-data.returns"></a><h4>Returns</h4> |
| <p> the source, if one was found, otherwise <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p> |
| <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-wakeup"></a><h3>g_main_context_wakeup ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_wakeup (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>If <em class="parameter"><code>context</code></em> |
| is currently blocking in <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a> |
| waiting for a source to become ready, cause it to stop blocking |
| and return. Otherwise, cause the next invocation of |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a> to return without blocking.</p> |
| <p>This API is useful for low-level control over <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>; for |
| example, integrating it with main loop implementations such as |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a>.</p> |
| <p>Another related use for this function is when implementing a main |
| loop with a termination condition, computed from multiple threads:</p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="preproc">#define</span><span class="normal"> NUM_TASKS </span><span class="number">10</span> |
| <span class="keyword">static</span><span class="normal"> </span><span class="keyword">volatile</span><span class="normal"> </span><span class="usertype">gint</span><span class="normal"> tasks_remaining </span><span class="symbol">=</span><span class="normal"> NUM_TASKS</span><span class="symbol">;</span> |
| <span class="symbol">...</span> |
| <span class="normal"> </span> |
| <span class="keyword">while</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-Atomic-Operations.html#g-atomic-int-get">g_atomic_int_get</a></span><span class="normal"> </span><span class="symbol">(&</span><span class="normal">tasks_remaining</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">!=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">)</span> |
| <span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-context-iteration">g_main_context_iteration</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p></p> |
| <p>Then in a thread:</p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="function">perform_work</span><span class="symbol">();</span> |
| |
| <span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-Atomic-Operations.html#g-atomic-int-dec-and-test">g_atomic_int_dec_and_test</a></span><span class="normal"> </span><span class="symbol">(&</span><span class="normal">tasks_remaining</span><span class="symbol">))</span> |
| <span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-context-wakeup">g_main_context_wakeup</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p></p> |
| <div class="refsect3"> |
| <a name="g-main-context-wakeup.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-acquire"></a><h3>g_main_context_acquire ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_main_context_acquire (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Tries to become the owner of the specified context. |
| If some other thread is the owner of the context, |
| returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> immediately. Ownership is properly |
| recursive: the owner can require ownership again |
| and will release ownership when <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-release" title="g_main_context_release ()"><code class="function">g_main_context_release()</code></a> |
| is called as many times as <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a>.</p> |
| <p>You must be the owner of a context before you |
| can call <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-prepare" title="g_main_context_prepare ()"><code class="function">g_main_context_prepare()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a>, |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-check" title="g_main_context_check ()"><code class="function">g_main_context_check()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-dispatch" title="g_main_context_dispatch ()"><code class="function">g_main_context_dispatch()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-acquire.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-acquire.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the operation succeeded, and |
| this thread is now the owner of <em class="parameter"><code>context</code></em> |
| .</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-release"></a><h3>g_main_context_release ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_release (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Releases ownership of a context previously acquired by this thread |
| with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a>. If the context was acquired multiple |
| times, the ownership will be released only when <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-release" title="g_main_context_release ()"><code class="function">g_main_context_release()</code></a> |
| is called as many times as it was acquired.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-release.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-is-owner"></a><h3>g_main_context_is_owner ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_main_context_is_owner (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Determines whether this thread holds the (recursive) |
| ownership of this <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>. This is useful to |
| know before waiting on another thread that may be |
| blocking to get ownership of <em class="parameter"><code>context</code></em> |
| .</p> |
| <div class="refsect3"> |
| <a name="g-main-context-is-owner.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-is-owner.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if current thread is owner of <em class="parameter"><code>context</code></em> |
| .</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-10.html#api-index-2.10">2.10</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-wait"></a><h3>g_main_context_wait ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_main_context_wait (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Threads.html#GCond" title="struct GCond"><span class="type">GCond</span></a> *cond</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Threads.html#GMutex" title="union GMutex"><span class="type">GMutex</span></a> *mutex</code></em>);</pre> |
| <p>Tries to become the owner of the specified context, |
| as with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a>. But if another thread |
| is the owner, atomically drop <em class="parameter"><code>mutex</code></em> |
| and wait on <em class="parameter"><code>cond</code></em> |
| until |
| that owner releases ownership or until <em class="parameter"><code>cond</code></em> |
| is signaled, then |
| try again (once) to become the owner.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-wait.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cond</p></td> |
| <td class="parameter_description"><p>a condition variable</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>mutex</p></td> |
| <td class="parameter_description"><p>a mutex, currently held</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-wait.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the operation succeeded, and |
| this thread is now the owner of <em class="parameter"><code>context</code></em> |
| .</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-prepare"></a><h3>g_main_context_prepare ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_main_context_prepare (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> *priority</code></em>);</pre> |
| <p>Prepares to poll sources within a main loop. The resulting information |
| for polling is determined by calling <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a>.</p> |
| <p>You must have successfully acquired the context with |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a> before you may call this function.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-prepare.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>priority</p></td> |
| <td class="parameter_description"><p>location to store priority of highest priority |
| source already ready.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-prepare.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if some source is ready to be dispatched |
| prior to polling.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-query"></a><h3>g_main_context_query ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| g_main_context_query (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> max_priority</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> *timeout_</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> n_fds</code></em>);</pre> |
| <p>Determines information necessary to poll this main loop.</p> |
| <p>You must have successfully acquired the context with |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a> before you may call this function.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-query.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>max_priority</p></td> |
| <td class="parameter_description"><p>maximum priority source to check</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>timeout_</p></td> |
| <td class="parameter_description"><p> location to store timeout to be used in polling. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>fds</p></td> |
| <td class="parameter_description"><p> location to |
| store <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> records that need to be polled. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Out parameter, where caller must allocate storage."><span class="acronym">out caller-allocates</span></acronym>][<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=n_fds]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>n_fds</p></td> |
| <td class="parameter_description"><p> length of <em class="parameter"><code>fds</code></em> |
| . </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter for input. Default is transfer none."><span class="acronym">in</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-query.returns"></a><h4>Returns</h4> |
| <p> the number of records actually stored in <em class="parameter"><code>fds</code></em> |
| , |
| or, if more than <em class="parameter"><code>n_fds</code></em> |
| records need to be stored, the number |
| of records that need to be stored.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-check"></a><h3>g_main_context_check ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| g_main_context_check (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> max_priority</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> n_fds</code></em>);</pre> |
| <p>Passes the results of polling back to the main loop.</p> |
| <p>You must have successfully acquired the context with |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a> before you may call this function.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-check.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>max_priority</p></td> |
| <td class="parameter_description"><p>the maximum numerical priority of sources to check</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>fds</p></td> |
| <td class="parameter_description"><p> array of <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a>'s that was passed to |
| the last call to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=n_fds]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>n_fds</p></td> |
| <td class="parameter_description"><p>return value of <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-query" title="g_main_context_query ()"><code class="function">g_main_context_query()</code></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-check.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if some sources are ready to be dispatched.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-dispatch"></a><h3>g_main_context_dispatch ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_dispatch (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Dispatches all pending sources.</p> |
| <p>You must have successfully acquired the context with |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a> before you may call this function.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-dispatch.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-set-poll-func"></a><h3>g_main_context_set_poll_func ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_set_poll_func (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFunc" title="GPollFunc ()"><span class="type">GPollFunc</span></a> func</code></em>);</pre> |
| <p>Sets the function to use to handle polling of file descriptors. It |
| will be used instead of the <code class="function">poll()</code> system call |
| (or GLib's replacement function, which is used where |
| <code class="function">poll()</code> isn't available).</p> |
| <p>This function could possibly be used to integrate the GLib event |
| loop with an external event loop.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-set-poll-func.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>func</p></td> |
| <td class="parameter_description"><p>the function to call to poll all file descriptors</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-get-poll-func"></a><h3>g_main_context_get_poll_func ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GPollFunc" title="GPollFunc ()"><span class="returnvalue">GPollFunc</span></a> |
| g_main_context_get_poll_func (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Gets the poll function set by <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-set-poll-func" title="g_main_context_set_poll_func ()"><code class="function">g_main_context_set_poll_func()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-get-poll-func.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-main-context-get-poll-func.returns"></a><h4>Returns</h4> |
| <p> the poll function</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GPollFunc"></a><h3>GPollFunc ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| <span class="c_punctuation">(</span>*GPollFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *ufds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> nfsd</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> timeout_</code></em>);</pre> |
| <p>Specifies the type of function passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-set-poll-func" title="g_main_context_set_poll_func ()"><code class="function">g_main_context_set_poll_func()</code></a>. |
| The semantics of the function should match those of the <code class="function">poll()</code> system call.</p> |
| <div class="refsect3"> |
| <a name="GPollFunc.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>ufds</p></td> |
| <td class="parameter_description"><p>an array of <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> elements</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>nfsd</p></td> |
| <td class="parameter_description"><p>the number of elements in <em class="parameter"><code>ufds</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>timeout_</p></td> |
| <td class="parameter_description"><p>the maximum time to wait for an event of the file descriptors. |
| A negative value indicates an infinite timeout.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="GPollFunc.returns"></a><h4>Returns</h4> |
| <p> the number of <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> elements which have events or errors |
| reported, or -1 if an error occurred.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-add-poll"></a><h3>g_main_context_add_poll ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_add_poll (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> priority</code></em>);</pre> |
| <p>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 <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-unix-fd" title="g_source_add_unix_fd ()"><code class="function">g_source_add_unix_fd()</code></a> instead.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-add-poll.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for the default context). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>fd</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> structure holding information about a file |
| descriptor to watch.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>priority</p></td> |
| <td class="parameter_description"><p>the priority for this file descriptor which should be |
| the same as the priority used for <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> to ensure that the |
| file descriptor is polled whenever the results may be needed.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-remove-poll"></a><h3>g_main_context_remove_poll ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_remove_poll (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);</pre> |
| <p>Removes file descriptor from the set of file descriptors to be |
| polled for a particular context.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-remove-poll.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>fd</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> descriptor previously added with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-add-poll" title="g_main_context_add_poll ()"><code class="function">g_main_context_add_poll()</code></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-depth"></a><h3>g_main_depth ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| g_main_depth (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p>Returns the depth of the stack of calls to |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-dispatch" title="g_main_context_dispatch ()"><code class="function">g_main_context_dispatch()</code></a> on any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> in the current thread. |
| That is, when called from the toplevel, it gives 0. When |
| called from within a callback from <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a> |
| (or <a class="link" href="glib-The-Main-Event-Loop.html#g-main-loop-run" title="g_main_loop_run ()"><code class="function">g_main_loop_run()</code></a>, etc.) it returns 1. When called from within |
| a callback to a recursive call to <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-iteration" title="g_main_context_iteration ()"><code class="function">g_main_context_iteration()</code></a>, |
| it returns 2. And so forth.</p> |
| <p>This function is useful in a situation like the following: |
| Imagine an extremely simple "garbage collected" system.</p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19 |
| 20 |
| 21 |
| 22 |
| 23 |
| 24 |
| 25 |
| 26 |
| 27</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="usertype">GList</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">free_list</span><span class="symbol">;</span> |
| |
| <span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span> |
| <span class="function">allocate_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">gsize</span><span class="normal"> size</span><span class="symbol">)</span> |
| <span class="cbracket">{</span><span class="normal"> </span> |
| <span class="normal"> </span><span class="usertype">gpointer</span><span class="normal"> result </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Allocation.html#g-malloc">g_malloc</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">size</span><span class="symbol">);</span> |
| <span class="normal"> free_list </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-prepend">g_list_prepend</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">free_list</span><span class="symbol">,</span><span class="normal"> result</span><span class="symbol">);</span> |
| <span class="normal"> </span><span class="keyword">return</span><span class="normal"> result</span><span class="symbol">;</span> |
| <span class="cbracket">}</span> |
| |
| <span class="type">void</span> |
| <span class="function">free_allocated_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> </span><span class="usertype">GList</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">l</span><span class="symbol">;</span> |
| <span class="normal"> </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">l </span><span class="symbol">=</span><span class="normal"> free_list</span><span class="symbol">;</span><span class="normal"> l</span><span class="symbol">;</span><span class="normal"> l </span><span class="symbol">=</span><span class="normal"> l</span><span class="symbol">-></span><span class="normal">next</span><span class="symbol">);</span> |
| <span class="normal"> </span><span class="function"><a href="glib-Memory-Allocation.html#g-free">g_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">l</span><span class="symbol">-></span><span class="normal">data</span><span class="symbol">);</span> |
| <span class="normal"> </span><span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-free">g_list_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">free_list</span><span class="symbol">);</span> |
| <span class="normal"> free_list </span><span class="symbol">=</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">;</span> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| |
| <span class="symbol">[...]</span> |
| |
| <span class="keyword">while</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">);</span><span class="normal"> </span> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-context-iteration">g_main_context_iteration</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">);</span> |
| <span class="normal"> </span><span class="function">free_allocated_memory</span><span class="symbol">();</span> |
| <span class="normal"> </span><span class="cbracket">}</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p></p> |
| <p>This works from an application, however, if you want to do the same |
| thing from a library, it gets more difficult, since you no longer |
| control the main loop. You might think you can simply use an idle |
| function to make the call to <code class="function">free_allocated_memory()</code>, but that |
| doesn't work, since the idle function could be called from a |
| recursive callback. This can be fixed by using <a class="link" href="glib-The-Main-Event-Loop.html#g-main-depth" title="g_main_depth ()"><code class="function">g_main_depth()</code></a></p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19 |
| 20 |
| 21 |
| 22 |
| 23 |
| 24 |
| 25 |
| 26 |
| 27 |
| 28 |
| 29 |
| 30</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span> |
| <span class="function">allocate_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">gsize</span><span class="normal"> size</span><span class="symbol">)</span> |
| <span class="cbracket">{</span><span class="normal"> </span> |
| <span class="normal"> </span><span class="usertype">FreeListBlock</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">block </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Allocation.html#g-new">g_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">FreeListBlock</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">);</span> |
| <span class="normal"> block</span><span class="symbol">-></span><span class="normal">mem </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Memory-Allocation.html#g-malloc">g_malloc</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">size</span><span class="symbol">);</span> |
| <span class="normal"> block</span><span class="symbol">-></span><span class="normal">depth </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-depth">g_main_depth</a></span><span class="normal"> </span><span class="symbol">();</span><span class="normal"> </span> |
| <span class="normal"> free_list </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-prepend">g_list_prepend</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">free_list</span><span class="symbol">,</span><span class="normal"> block</span><span class="symbol">);</span> |
| <span class="normal"> </span><span class="keyword">return</span><span class="normal"> block</span><span class="symbol">-></span><span class="normal">mem</span><span class="symbol">;</span> |
| <span class="cbracket">}</span> |
| |
| <span class="type">void</span> |
| <span class="function">free_allocated_memory</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> </span><span class="usertype">GList</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">l</span><span class="symbol">;</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="type">int</span><span class="normal"> depth </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-depth">g_main_depth</a></span><span class="normal"> </span><span class="symbol">();</span> |
| <span class="normal"> </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">l </span><span class="symbol">=</span><span class="normal"> free_list</span><span class="symbol">;</span><span class="normal"> l</span><span class="symbol">;</span><span class="normal"> </span><span class="symbol">);</span> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <span class="normal"> </span><span class="usertype">GList</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">next </span><span class="symbol">=</span><span class="normal"> l</span><span class="symbol">-></span><span class="normal">next</span><span class="symbol">;</span> |
| <span class="normal"> </span><span class="usertype">FreeListBlock</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">block </span><span class="symbol">=</span><span class="normal"> l</span><span class="symbol">-></span><span class="normal">data</span><span class="symbol">;</span> |
| <span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">block</span><span class="symbol">-></span><span class="normal">depth </span><span class="symbol">></span><span class="normal"> depth</span><span class="symbol">)</span> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <span class="normal"> </span><span class="function"><a href="glib-Memory-Allocation.html#g-free">g_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">block</span><span class="symbol">-></span><span class="normal">mem</span><span class="symbol">);</span> |
| <span class="normal"> </span><span class="function"><a href="glib-Memory-Allocation.html#g-free">g_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">block</span><span class="symbol">);</span> |
| <span class="normal"> free_list </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-delete-link">g_list_delete_link</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">free_list</span><span class="symbol">,</span><span class="normal"> l</span><span class="symbol">);</span> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| <span class="normal"> </span> |
| <span class="normal"> l </span><span class="symbol">=</span><span class="normal"> next</span><span class="symbol">;</span> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| <span class="normal"> </span><span class="cbracket">}</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p></p> |
| <p>There is a temptation to use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-depth" title="g_main_depth ()"><code class="function">g_main_depth()</code></a> to solve |
| problems with reentrancy. For instance, while waiting for data |
| to be received from the network in response to a menu item, |
| the menu item might be selected again. It might seem that |
| one could make the menu item's callback return immediately |
| and do nothing if <a class="link" href="glib-The-Main-Event-Loop.html#g-main-depth" title="g_main_depth ()"><code class="function">g_main_depth()</code></a> returns a value greater than 1. |
| However, this should be avoided since the user then sees selecting |
| the menu item do nothing. Furthermore, you'll find yourself adding |
| these checks all over your code, since there are doubtless many, |
| many things that the user could do. Instead, you can use the |
| following techniques:</p> |
| <div class="orderedlist"><ol class="orderedlist" type="1"> |
| <li class="listitem"><p>Use <a href="http://developer.gnome.org/gtk3/GtkWidget.html#gtk-widget-set-sensitive"><code class="function">gtk_widget_set_sensitive()</code></a> or modal dialogs to prevent |
| the user from interacting with elements while the main |
| loop is recursing.</p></li> |
| <li class="listitem"><p>Avoid main loop recursion in situations where you can't handle |
| arbitrary callbacks. Instead, structure your code so that you |
| simply return to the main loop and then get called again when |
| there is more work to do.</p></li> |
| </ol></div> |
| <div class="refsect3"> |
| <a name="g-main-depth.returns"></a><h4>Returns</h4> |
| <p> The main loop recursion level in the current thread</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-current-source"></a><h3>g_main_current_source ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_main_current_source (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p>Returns the currently firing source for this thread.</p> |
| <div class="refsect3"> |
| <a name="g-main-current-source.returns"></a><h4>Returns</h4> |
| <p> The currently firing source or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p> |
| <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-12.html#api-index-2.12">2.12</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-set-poll-func"></a><h3>g_main_set_poll_func()</h3> |
| <pre class="programlisting">#define g_main_set_poll_func(func)</pre> |
| <div class="warning"> |
| <p><code class="literal">g_main_set_poll_func</code> has been deprecated since version 2.2 and should not be used in newly-written code.</p> |
| <p>Use <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-set-poll-func" title="g_main_context_set_poll_func ()"><code class="function">g_main_context_set_poll_func()</code></a> again</p> |
| </div> |
| <p>Sets the function to use for the handle polling of file descriptors |
| for the default main context.</p> |
| <div class="refsect3"> |
| <a name="g-main-set-poll-func.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>func</p></td> |
| <td class="parameter_description"><p>the function to call to poll all file descriptors</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-invoke"></a><h3>g_main_context_invoke ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_invoke (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre> |
| <p>Invokes a function in such a way that <em class="parameter"><code>context</code></em> |
| is owned during the |
| invocation of <em class="parameter"><code>function</code></em> |
| .</p> |
| <p>If <em class="parameter"><code>context</code></em> |
| is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> then the global default main context — as |
| returned by <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-default" title="g_main_context_default ()"><code class="function">g_main_context_default()</code></a> — is used.</p> |
| <p>If <em class="parameter"><code>context</code></em> |
| is owned by the current thread, <em class="parameter"><code>function</code></em> |
| is called |
| directly. Otherwise, if <em class="parameter"><code>context</code></em> |
| is the thread-default main context |
| of the current thread and <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-acquire" title="g_main_context_acquire ()"><code class="function">g_main_context_acquire()</code></a> succeeds, then |
| <em class="parameter"><code>function</code></em> |
| is called and <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-release" title="g_main_context_release ()"><code class="function">g_main_context_release()</code></a> is called |
| afterwards.</p> |
| <p>In any other case, an idle source is created to call <em class="parameter"><code>function</code></em> |
| and |
| that source is attached to <em class="parameter"><code>context</code></em> |
| (presumably to be run in another |
| thread). The idle source is attached with <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a> |
| priority. If you want a different priority, use |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-invoke-full" title="g_main_context_invoke_full ()"><code class="function">g_main_context_invoke_full()</code></a>.</p> |
| <p>Note that, as with normal idle functions, <em class="parameter"><code>function</code></em> |
| should probably |
| return <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>. If it returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, it will be continuously run in a |
| loop (and may prevent this call from returning).</p> |
| <div class="refsect3"> |
| <a name="g-main-context-invoke.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-28.html#api-index-2.28">2.28</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-invoke-full"></a><h3>g_main_context_invoke_full ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_invoke_full (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> priority</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p>Invokes a function in such a way that <em class="parameter"><code>context</code></em> |
| is owned during the |
| invocation of <em class="parameter"><code>function</code></em> |
| .</p> |
| <p>This function is the same as <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-invoke" title="g_main_context_invoke ()"><code class="function">g_main_context_invoke()</code></a> except that it |
| lets you specify the priority incase <em class="parameter"><code>function</code></em> |
| ends up being |
| scheduled as an idle and also lets you give a <a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> for <em class="parameter"><code>data</code></em> |
| .</p> |
| <p><em class="parameter"><code>notify</code></em> |
| should not assume that it is called from any particular |
| thread or with any particular context acquired.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-invoke-full.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>priority</p></td> |
| <td class="parameter_description"><p>the priority at which to run <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>notify</p></td> |
| <td class="parameter_description"><p> a function to call when <em class="parameter"><code>data</code></em> |
| is no longer in use, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-28.html#api-index-2.28">2.28</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-get-thread-default"></a><h3>g_main_context_get_thread_default ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| g_main_context_get_thread_default (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p>Gets the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> 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 |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref-thread-default" title="g_main_context_ref_thread_default ()"><code class="function">g_main_context_ref_thread_default()</code></a> to get a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> to add |
| their <a href="glib-The-Main-Event-Loop.html#GSource"><span class="type">GSources</span></a> to. (Note that even in single-threaded |
| programs applications may sometimes want to temporarily push a |
| non-default context, so it is not safe to assume that this will |
| always return <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if you are running in the default thread.)</p> |
| <p>If you need to hold a reference on the context, use |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref-thread-default" title="g_main_context_ref_thread_default ()"><code class="function">g_main_context_ref_thread_default()</code></a> instead.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-get-thread-default.returns"></a><h4>Returns</h4> |
| <p> the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, or |
| <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the thread-default context is the global default context. </p> |
| <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-ref-thread-default"></a><h3>g_main_context_ref_thread_default ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| g_main_context_ref_thread_default (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p>Gets the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> for this thread, as with |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()"><code class="function">g_main_context_get_thread_default()</code></a>, but also adds a reference to |
| it with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-ref" title="g_main_context_ref ()"><code class="function">g_main_context_ref()</code></a>. In addition, unlike |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()"><code class="function">g_main_context_get_thread_default()</code></a>, if the thread-default context |
| is the global default context, this will return that <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| (with a ref added to it) rather than returning <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-ref-thread-default.returns"></a><h4>Returns</h4> |
| <p> the thread-default <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>. Unref |
| with <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-unref" title="g_main_context_unref ()"><code class="function">g_main_context_unref()</code></a> when you are done with it. </p> |
| <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-push-thread-default"></a><h3>g_main_context_push_thread_default ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_push_thread_default (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Acquires <em class="parameter"><code>context</code></em> |
| 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 <em class="parameter"><code>context</code></em> |
| 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 <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-get-thread-default" title="g_main_context_get_thread_default ()"><code class="function">g_main_context_get_thread_default()</code></a>, |
| not the one returned by <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-default" title="g_main_context_default ()"><code class="function">g_main_context_default()</code></a>, so it does not affect |
| the context used by functions like <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>.</p> |
| <p>Normally you would call this function shortly after creating a new |
| thread, passing it a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> which will be run by a |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainLoop" title="GMainLoop"><span class="type">GMainLoop</span></a> in that thread, to set a new default context for all |
| async operations in that thread. In this case you may not need to |
| ever call <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pop-thread-default" title="g_main_context_pop_thread_default ()"><code class="function">g_main_context_pop_thread_default()</code></a>, assuming you want the |
| new <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> to be the default for the whole lifecycle of the |
| thread.</p> |
| <p>If you don't have control over how the new thread was created (e.g. |
| in the new thread isn't newly created, or if the thread life |
| cycle is managed by a <a class="link" href="glib-Thread-Pools.html#GThreadPool" title="struct GThreadPool"><span class="type">GThreadPool</span></a>), it is always suggested to wrap |
| the logic that needs to use the new <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> inside a |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-push-thread-default" title="g_main_context_push_thread_default ()"><code class="function">g_main_context_push_thread_default()</code></a> / <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pop-thread-default" title="g_main_context_pop_thread_default ()"><code class="function">g_main_context_pop_thread_default()</code></a> |
| pair, otherwise threads that are re-used will end up never explicitly |
| releasing the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> reference they hold.</p> |
| <p>In some cases you may want to schedule a single operation in a |
| non-default context, or temporarily use a non-default context in |
| the main thread. In that case, you can wrap the call to the |
| asynchronous operation inside a |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-push-thread-default" title="g_main_context_push_thread_default ()"><code class="function">g_main_context_push_thread_default()</code></a> / |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-pop-thread-default" title="g_main_context_pop_thread_default ()"><code class="function">g_main_context_pop_thread_default()</code></a> pair, but it is up to you to |
| ensure that no other asynchronous operations accidentally get |
| started while the non-default context is active.</p> |
| <p>Beware that libraries that predate this function may not correctly |
| handle being used from a thread with a thread-default context. Eg, |
| see <a href="https://developer.gnome.org/gio/unstable/GFile.html#g-file-supports-thread-contexts"><code class="function">g_file_supports_thread_contexts()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-main-context-push-thread-default.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for the global default context. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-main-context-pop-thread-default"></a><h3>g_main_context_pop_thread_default ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_main_context_pop_thread_default (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Pops <em class="parameter"><code>context</code></em> |
| off the thread-default context stack (verifying that |
| it was on the top of the stack).</p> |
| <div class="refsect3"> |
| <a name="g-main-context-pop-thread-default.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> object, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-timeout-source-new"></a><h3>g_timeout_source_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_timeout_source_new (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> interval</code></em>);</pre> |
| <p>Creates a new timeout source.</p> |
| <p>The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be |
| executed.</p> |
| <p>The interval given is in terms of monotonic time, not wall clock |
| time. See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-timeout-source-new.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>interval</p></td> |
| <td class="parameter_description"><p>the timeout interval in milliseconds.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-timeout-source-new.returns"></a><h4>Returns</h4> |
| <p> the newly-created timeout source</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-timeout-source-new-seconds"></a><h3>g_timeout_source_new_seconds ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_timeout_source_new_seconds (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> interval</code></em>);</pre> |
| <p>Creates a new timeout source.</p> |
| <p>The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be |
| executed.</p> |
| <p>The scheduling granularity/accuracy of this timeout source will be |
| in seconds.</p> |
| <p>The interval given in terms of monotonic time, not wall clock time. |
| See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-timeout-source-new-seconds.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>interval</p></td> |
| <td class="parameter_description"><p>the timeout interval in seconds</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-timeout-source-new-seconds.returns"></a><h4>Returns</h4> |
| <p> the newly-created timeout source</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-14.html#api-index-2.14">2.14</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-timeout-add"></a><h3>g_timeout_add ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_timeout_add (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> interval</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre> |
| <p>Sets a function to be called at regular intervals, with the default |
| priority, <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a>. The function is called repeatedly |
| until it returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, at which point the timeout is automatically |
| destroyed and the function will not be called again. The first call |
| to the function will be at the end of the first <em class="parameter"><code>interval</code></em> |
| .</p> |
| <p>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).</p> |
| <p>See <a class="link" href="glib-The-Main-Event-Loop.html#mainloop-memory-management" title="Memory management of sources">memory management of sources</a> for details |
| on how to handle the return value and memory management of <em class="parameter"><code>data</code></em> |
| .</p> |
| <p>If you want to have a timer in the "seconds" range and do not care |
| about the exact time of the first call of the timer, use the |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds" title="g_timeout_add_seconds ()"><code class="function">g_timeout_add_seconds()</code></a> function; this function allows for more |
| optimizations and more efficient system power usage.</p> |
| <p>This internally creates a main loop source using <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new" title="g_timeout_source_new ()"><code class="function">g_timeout_source_new()</code></a> |
| and attaches it to the global <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>, so |
| the callback will be invoked in whichever thread is running that main |
| context. You can do these steps manually if you need greater control or to |
| use a custom main context.</p> |
| <p>The interval given is in terms of monotonic time, not wall clock |
| time. See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-timeout-add.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>interval</p></td> |
| <td class="parameter_description"><p>the time between calls to the function, in milliseconds |
| (1/1000ths of a second)</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-timeout-add.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) of the event source.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-timeout-add-full"></a><h3>g_timeout_add_full ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_timeout_add_full (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> priority</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> interval</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p>Sets a function to be called at regular intervals, with the given |
| priority. The function is called repeatedly until it returns |
| <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, at which point the timeout is automatically destroyed and |
| the function will not be called again. The <em class="parameter"><code>notify</code></em> |
| function is |
| called when the timeout is destroyed. The first call to the |
| function will be at the end of the first <em class="parameter"><code>interval</code></em> |
| .</p> |
| <p>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).</p> |
| <p>See <a class="link" href="glib-The-Main-Event-Loop.html#mainloop-memory-management" title="Memory management of sources">memory management of sources</a> for details |
| on how to handle the return value and memory management of <em class="parameter"><code>data</code></em> |
| .</p> |
| <p>This internally creates a main loop source using <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new" title="g_timeout_source_new ()"><code class="function">g_timeout_source_new()</code></a> |
| and attaches it to the global <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>, so |
| the callback will be invoked in whichever thread is running that main |
| context. You can do these steps manually if you need greater control or to |
| use a custom main context.</p> |
| <p>The interval given in terms of monotonic time, not wall clock time. |
| See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.</p> |
| <p><span class="annotation">[<acronym title="Rename the original symbol's name to SYMBOL."><span class="acronym">rename-to</span></acronym> g_timeout_add]</span></p> |
| <div class="refsect3"> |
| <a name="g-timeout-add-full.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>priority</p></td> |
| <td class="parameter_description"><p>the priority of the timeout source. Typically this will be in |
| the range between <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a> and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH:CAPS" title="G_PRIORITY_HIGH"><span class="type">G_PRIORITY_HIGH</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>interval</p></td> |
| <td class="parameter_description"><p>the time between calls to the function, in milliseconds |
| (1/1000ths of a second)</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>notify</p></td> |
| <td class="parameter_description"><p> function to call when the timeout is removed, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-timeout-add-full.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) of the event source.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-timeout-add-seconds"></a><h3>g_timeout_add_seconds ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_timeout_add_seconds (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> interval</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre> |
| <p>Sets a function to be called at regular intervals with the default |
| priority, <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a>. The function is called repeatedly until |
| it returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, at which point the timeout is automatically destroyed |
| and the function will not be called again.</p> |
| <p>This internally creates a main loop source using |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new-seconds" title="g_timeout_source_new_seconds ()"><code class="function">g_timeout_source_new_seconds()</code></a> and attaches it to the main loop context |
| using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can do these steps manually if you need |
| greater control. Also see <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds-full" title="g_timeout_add_seconds_full ()"><code class="function">g_timeout_add_seconds_full()</code></a>.</p> |
| <p>Note that the first call of the timer may not be precise for timeouts |
| of one second. If you need finer precision and have such a timeout, |
| you may want to use <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a> instead.</p> |
| <p>See <a class="link" href="glib-The-Main-Event-Loop.html#mainloop-memory-management" title="Memory management of sources">memory management of sources</a> for details |
| on how to handle the return value and memory management of <em class="parameter"><code>data</code></em> |
| .</p> |
| <p>The interval given is in terms of monotonic time, not wall clock |
| time. See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-timeout-add-seconds.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>interval</p></td> |
| <td class="parameter_description"><p>the time between calls to the function, in seconds</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-timeout-add-seconds.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) of the event source.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-14.html#api-index-2.14">2.14</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-timeout-add-seconds-full"></a><h3>g_timeout_add_seconds_full ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_timeout_add_seconds_full (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> priority</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> interval</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p>Sets a function to be called at regular intervals, with <em class="parameter"><code>priority</code></em> |
| . |
| The function is called repeatedly until it returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, at which |
| point the timeout is automatically destroyed and the function will |
| not be called again.</p> |
| <p>Unlike <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>, this function operates at whole second granularity. |
| The initial starting point of the timer is determined by the implementation |
| and the implementation is expected to group multiple timers together so that |
| they fire all at the same time. |
| To allow this grouping, the <em class="parameter"><code>interval</code></em> |
| to the first timer is rounded |
| and can deviate up to one second from the specified interval. |
| Subsequent timer iterations will generally run at the specified interval.</p> |
| <p>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 <em class="parameter"><code>interval</code></em> |
| </p> |
| <p>See <a class="link" href="glib-The-Main-Event-Loop.html#mainloop-memory-management" title="Memory management of sources">memory management of sources</a> for details |
| on how to handle the return value and memory management of <em class="parameter"><code>data</code></em> |
| .</p> |
| <p>If you want timing more precise than whole seconds, use <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a> |
| instead.</p> |
| <p>The grouping of timers to fire at the same time results in a more power |
| and CPU efficient behavior so if your timer is in multiples of seconds |
| and you don't require the first timer exactly one second from now, the |
| use of <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-seconds" title="g_timeout_add_seconds ()"><code class="function">g_timeout_add_seconds()</code></a> is preferred over <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>.</p> |
| <p>This internally creates a main loop source using |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-source-new-seconds" title="g_timeout_source_new_seconds ()"><code class="function">g_timeout_source_new_seconds()</code></a> and attaches it to the main loop context |
| using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can do these steps manually if you need |
| greater control.</p> |
| <p>The interval given is in terms of monotonic time, not wall clock |
| time. See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.</p> |
| <p><span class="annotation">[<acronym title="Rename the original symbol's name to SYMBOL."><span class="acronym">rename-to</span></acronym> g_timeout_add_seconds]</span></p> |
| <div class="refsect3"> |
| <a name="g-timeout-add-seconds-full.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>priority</p></td> |
| <td class="parameter_description"><p>the priority of the timeout source. Typically this will be in |
| the range between <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a> and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH:CAPS" title="G_PRIORITY_HIGH"><span class="type">G_PRIORITY_HIGH</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>interval</p></td> |
| <td class="parameter_description"><p>the time between calls to the function, in seconds</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>notify</p></td> |
| <td class="parameter_description"><p> function to call when the timeout is removed, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-timeout-add-seconds-full.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) of the event source.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-14.html#api-index-2.14">2.14</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-idle-source-new"></a><h3>g_idle_source_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_idle_source_new (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p>Creates a new idle source.</p> |
| <p>The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be |
| executed. Note that the default priority for idle sources is |
| <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE"><code class="literal">G_PRIORITY_DEFAULT_IDLE</code></a>, as compared to other sources which |
| have a default priority of <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><code class="literal">G_PRIORITY_DEFAULT</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-idle-source-new.returns"></a><h4>Returns</h4> |
| <p> the newly-created idle source</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-idle-add"></a><h3>g_idle_add ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_idle_add (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre> |
| <p>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, <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a>. If the function |
| returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> it is automatically removed from the list of event |
| sources and will not be called again.</p> |
| <p>See <a class="link" href="glib-The-Main-Event-Loop.html#mainloop-memory-management" title="Memory management of sources">memory management of sources</a> for details |
| on how to handle the return value and memory management of <em class="parameter"><code>data</code></em> |
| .</p> |
| <p>This internally creates a main loop source using <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-source-new" title="g_idle_source_new ()"><code class="function">g_idle_source_new()</code></a> |
| and attaches it to the global <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>, so |
| the callback will be invoked in whichever thread is running that main |
| context. You can do these steps manually if you need greater control or to |
| use a custom main context.</p> |
| <div class="refsect3"> |
| <a name="g-idle-add.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| .</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-idle-add.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) of the event source.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-idle-add-full"></a><h3>g_idle_add_full ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_idle_add_full (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> priority</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p>Adds a function to be called whenever there are no higher priority |
| events pending. If the function returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> it is automatically |
| removed from the list of event sources and will not be called again.</p> |
| <p>See <a class="link" href="glib-The-Main-Event-Loop.html#mainloop-memory-management" title="Memory management of sources">memory management of sources</a> for details |
| on how to handle the return value and memory management of <em class="parameter"><code>data</code></em> |
| .</p> |
| <p>This internally creates a main loop source using <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-source-new" title="g_idle_source_new ()"><code class="function">g_idle_source_new()</code></a> |
| and attaches it to the global <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>, so |
| the callback will be invoked in whichever thread is running that main |
| context. You can do these steps manually if you need greater control or to |
| use a custom main context.</p> |
| <p><span class="annotation">[<acronym title="Rename the original symbol's name to SYMBOL."><span class="acronym">rename-to</span></acronym> g_idle_add]</span></p> |
| <div class="refsect3"> |
| <a name="g-idle-add-full.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>priority</p></td> |
| <td class="parameter_description"><p>the priority of the idle source. Typically this will be in the |
| range between <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a> and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE"><span class="type">G_PRIORITY_HIGH_IDLE</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>notify</p></td> |
| <td class="parameter_description"><p> function to call when the idle is removed, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-idle-add-full.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) of the event source.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-idle-remove-by-data"></a><h3>g_idle_remove_by_data ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_idle_remove_by_data (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre> |
| <p>Removes the idle function with the given data.</p> |
| <div class="refsect3"> |
| <a name="g-idle-remove-by-data.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>the data for the idle source's callback.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-idle-remove-by-data.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if an idle source was found and removed.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GChildWatchFunc"></a><h3>GChildWatchFunc ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| <span class="c_punctuation">(</span>*GChildWatchFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> status</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre> |
| <p>Prototype of a <span class="type">GChildWatchSource</span> callback, called when a child |
| process has exited. To interpret <em class="parameter"><code>status</code></em> |
| , see the documentation |
| for <a class="link" href="glib-Spawning-Processes.html#g-spawn-check-exit-status" title="g_spawn_check_exit_status ()"><code class="function">g_spawn_check_exit_status()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="GChildWatchFunc.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>pid</p></td> |
| <td class="parameter_description"><p>the process id of the child process</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>status</p></td> |
| <td class="parameter_description"><p>Status information about the child process, encoded |
| in a platform-specific manner</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>user_data</p></td> |
| <td class="parameter_description"><p>user data passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add" title="g_child_watch_add ()"><code class="function">g_child_watch_add()</code></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-child-watch-source-new"></a><h3>g_child_watch_source_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_child_watch_source_new (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>);</pre> |
| <p>Creates a new child_watch source.</p> |
| <p>The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be |
| executed.</p> |
| <p>Note that child watch sources can only be used in conjunction with |
| <code class="literal">g_spawn...</code> when the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></a> flag is used.</p> |
| <p>Note that on platforms where <a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> must be explicitly closed |
| (see <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a>) <em class="parameter"><code>pid</code></em> |
| must not be closed while the |
| source is still active. Typically, you will want to call |
| <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a> in the callback function for the source.</p> |
| <p>Note further that using <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-source-new" title="g_child_watch_source_new ()"><code class="function">g_child_watch_source_new()</code></a> is not |
| compatible with calling <code class="literal">waitpid</code> with a nonpositive first |
| argument in the application. Calling <code class="function">waitpid()</code> for individual |
| pids will still work fine.</p> |
| <p>Similarly, on POSIX platforms, the <em class="parameter"><code>pid</code></em> |
| passed to this function must |
| be greater than 0 (i.e. this function must wait for a specific child, |
| and cannot wait for one of many children by using a nonpositive argument).</p> |
| <div class="refsect3"> |
| <a name="g-child-watch-source-new.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>pid</p></td> |
| <td class="parameter_description"><p>process to watch. On POSIX the positive pid of a child process. On |
| Windows a handle for a process (which doesn't have to be a child).</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-child-watch-source-new.returns"></a><h4>Returns</h4> |
| <p> the newly-created child watch source</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-4.html#api-index-2.4">2.4</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-child-watch-add"></a><h3>g_child_watch_add ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_child_watch_add (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GChildWatchFunc" title="GChildWatchFunc ()"><span class="type">GChildWatchFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre> |
| <p>Sets a function to be called when the child indicated by <em class="parameter"><code>pid</code></em> |
| |
| exits, at a default priority, <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS" title="G_PRIORITY_DEFAULT"><span class="type">G_PRIORITY_DEFAULT</span></a>.</p> |
| <p>If you obtain <em class="parameter"><code>pid</code></em> |
| from <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()"><code class="function">g_spawn_async()</code></a> or <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()"><code class="function">g_spawn_async_with_pipes()</code></a> |
| you will need to pass <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><span class="type">G_SPAWN_DO_NOT_REAP_CHILD</span></a> as flag to |
| the spawn function for the child watching to work.</p> |
| <p>Note that on platforms where <a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> must be explicitly closed |
| (see <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a>) <em class="parameter"><code>pid</code></em> |
| must not be closed while the |
| source is still active. Typically, you will want to call |
| <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a> in the callback function for the source.</p> |
| <p>GLib supports only a single callback per process id.</p> |
| <p>This internally creates a main loop source using |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-source-new" title="g_child_watch_source_new ()"><code class="function">g_child_watch_source_new()</code></a> and attaches it to the main loop context |
| using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can do these steps manually if you |
| need greater control.</p> |
| <div class="refsect3"> |
| <a name="g-child-watch-add.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>pid</p></td> |
| <td class="parameter_description"><p>process id to watch. On POSIX the positive pid of a child |
| process. On Windows a handle for a process (which doesn't have to be |
| a child).</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-child-watch-add.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) of the event source.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-4.html#api-index-2.4">2.4</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-child-watch-add-full"></a><h3>g_child_watch_add_full ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_child_watch_add_full (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> priority</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> pid</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GChildWatchFunc" title="GChildWatchFunc ()"><span class="type">GChildWatchFunc</span></a> function</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p>Sets a function to be called when the child indicated by <em class="parameter"><code>pid</code></em> |
| |
| exits, at the priority <em class="parameter"><code>priority</code></em> |
| .</p> |
| <p>If you obtain <em class="parameter"><code>pid</code></em> |
| from <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()"><code class="function">g_spawn_async()</code></a> or <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()"><code class="function">g_spawn_async_with_pipes()</code></a> |
| you will need to pass <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><span class="type">G_SPAWN_DO_NOT_REAP_CHILD</span></a> as flag to |
| the spawn function for the child watching to work.</p> |
| <p>In many programs, you will want to call <a class="link" href="glib-Spawning-Processes.html#g-spawn-check-exit-status" title="g_spawn_check_exit_status ()"><code class="function">g_spawn_check_exit_status()</code></a> |
| in the callback to determine whether or not the child exited |
| successfully.</p> |
| <p>Also, note that on platforms where <a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a> must be explicitly closed |
| (see <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a>) <em class="parameter"><code>pid</code></em> |
| must not be closed while the source |
| is still active. Typically, you should invoke <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a> |
| in the callback function for the source.</p> |
| <p>GLib supports only a single callback per process id.</p> |
| <p>This internally creates a main loop source using |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-source-new" title="g_child_watch_source_new ()"><code class="function">g_child_watch_source_new()</code></a> and attaches it to the main loop context |
| using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>. You can do these steps manually if you |
| need greater control.</p> |
| <p><span class="annotation">[<acronym title="Rename the original symbol's name to SYMBOL."><span class="acronym">rename-to</span></acronym> g_child_watch_add]</span></p> |
| <div class="refsect3"> |
| <a name="g-child-watch-add-full.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>priority</p></td> |
| <td class="parameter_description"><p>the priority of the idle source. Typically this will be in the |
| range between <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS" title="G_PRIORITY_DEFAULT_IDLE"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a> and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE"><span class="type">G_PRIORITY_HIGH_IDLE</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>pid</p></td> |
| <td class="parameter_description"><p>process to watch. On POSIX the positive pid of a child process. On |
| Windows a handle for a process (which doesn't have to be a child).</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>function</p></td> |
| <td class="parameter_description"><p>function to call</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>data to pass to <em class="parameter"><code>function</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>notify</p></td> |
| <td class="parameter_description"><p> function to call when the idle is removed, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-child-watch-add-full.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) of the event source.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-4.html#api-index-2.4">2.4</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-poll"></a><h3>g_poll ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| g_poll (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> nfds</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> timeout</code></em>);</pre> |
| <p>Polls <em class="parameter"><code>fds</code></em> |
| , as with the <code class="function">poll()</code> system call, but portably. (On |
| systems that don't have <code class="function">poll()</code>, it is emulated using <code class="function">select()</code>.) |
| This is used internally by <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, but it can be called |
| directly if you need to block until a file descriptor is ready, but |
| don't want to run the full main loop.</p> |
| <p>Each element of <em class="parameter"><code>fds</code></em> |
| is a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> describing a single file |
| descriptor to poll. The <code class="literal">fd</code> field indicates the file descriptor, |
| and the <code class="literal">events</code> field indicates the events to poll for. On return, |
| the <code class="literal">revents</code> fields will be filled with the events that actually |
| occurred.</p> |
| <p>On POSIX systems, the file descriptors in <em class="parameter"><code>fds</code></em> |
| can be any sort of |
| file descriptor, but the situation is much more complicated on |
| Windows. If you need to use <a class="link" href="glib-The-Main-Event-Loop.html#g-poll" title="g_poll ()"><code class="function">g_poll()</code></a> in code that has to run on |
| Windows, the easiest solution is to construct all of your |
| <a href="glib-The-Main-Event-Loop.html#GPollFD"><span class="type">GPollFDs</span></a> with <code class="function">g_io_channel_win32_make_pollfd()</code>.</p> |
| <div class="refsect3"> |
| <a name="g-poll.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>fds</p></td> |
| <td class="parameter_description"><p>file descriptors to poll</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>nfds</p></td> |
| <td class="parameter_description"><p>the number of file descriptors in <em class="parameter"><code>fds</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>timeout</p></td> |
| <td class="parameter_description"><p>amount of time to wait, in milliseconds, or -1 to wait forever</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-poll.returns"></a><h4>Returns</h4> |
| <p> the number of entries in <em class="parameter"><code>fds</code></em> |
| whose <code class="literal">revents</code> fields |
| were filled in, or 0 if the operation timed out, or -1 on error or |
| if the call was interrupted.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-20.html#api-index-2.20">2.20</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSourceDummyMarshal"></a><h3>GSourceDummyMarshal ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| <span class="c_punctuation">(</span>*GSourceDummyMarshal<span class="c_punctuation">)</span> (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> |
| <p>This is just a placeholder for <a href="https://developer.gnome.org/gobject/unstable/gobject-Closures.html#GClosureMarshal"><span class="type">GClosureMarshal</span></a>, |
| which cannot be used here for dependency reasons.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-new"></a><h3>g_source_new ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_source_new (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *source_funcs</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> struct_size</code></em>);</pre> |
| <p>Creates a new <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> structure. The size is specified to |
| allow creating structures derived from <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that contain |
| additional data. The size passed in must be at least |
| <code class="literal">sizeof (GSource)</code>.</p> |
| <p>The source will not initially be associated with any <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> |
| and must be added to one with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a> before it will be |
| executed.</p> |
| <div class="refsect3"> |
| <a name="g-source-new.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source_funcs</p></td> |
| <td class="parameter_description"><p>structure containing functions that implement |
| the sources behavior.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>struct_size</p></td> |
| <td class="parameter_description"><p>size of the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> structure to create.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-new.returns"></a><h4>Returns</h4> |
| <p> the newly-created <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-ref"></a><h3>g_source_ref ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="returnvalue">GSource</span></a> * |
| g_source_ref (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Increases the reference count on a source by one.</p> |
| <div class="refsect3"> |
| <a name="g-source-ref.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-ref.returns"></a><h4>Returns</h4> |
| <p> <em class="parameter"><code>source</code></em> |
| </p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-unref"></a><h3>g_source_unref ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_unref (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Decreases the reference count of a source by one. If the |
| resulting reference count is zero the source and associated |
| memory will be destroyed.</p> |
| <div class="refsect3"> |
| <a name="g-source-unref.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-set-funcs"></a><h3>g_source_set_funcs ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_set_funcs (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>);</pre> |
| <p>Sets the source functions (can be used to override |
| default implementations) of an unattached source.</p> |
| <div class="refsect3"> |
| <a name="g-source-set-funcs.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>funcs</p></td> |
| <td class="parameter_description"><p>the new <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-12.html#api-index-2.12">2.12</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-attach"></a><h3>g_source_attach ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_source_attach (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> *context</code></em>);</pre> |
| <p>Adds a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> to a <em class="parameter"><code>context</code></em> |
| so that it will be executed within |
| that context. Remove it by calling <a class="link" href="glib-The-Main-Event-Loop.html#g-source-destroy" title="g_source_destroy ()"><code class="function">g_source_destroy()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-source-attach.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>context</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> (if <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the default context will be used). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-attach.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) for the source within the |
| <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>. </p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-destroy"></a><h3>g_source_destroy ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_destroy (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Removes a source from its <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, if any, and mark it as |
| destroyed. The source cannot be subsequently added to another |
| context. It is safe to call this on sources which have already been |
| removed from their context.</p> |
| <div class="refsect3"> |
| <a name="g-source-destroy.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-is-destroyed"></a><h3>g_source_is_destroyed ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_source_is_destroyed (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Returns whether <em class="parameter"><code>source</code></em> |
| has been destroyed.</p> |
| <p>This is important when you operate upon your objects |
| from within idle handlers, but may have freed the object |
| before the dispatch of your idle handler.</p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19 |
| 20 |
| 21 |
| 22 |
| 23 |
| 24 |
| 25 |
| 26 |
| 27 |
| 28 |
| 29</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="glib-Basic-Types.html#gboolean">gboolean</a> </span> |
| <span class="function">idle_callback</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">gpointer</span><span class="normal"> data</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> </span><span class="usertype">SomeWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> data</span><span class="symbol">;</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="function"><a href="http://developer.gnome.org/gdk3/gdk3-Threads.html#GDK-THREADS-ENTER:CAPS">GDK_THREADS_ENTER</a></span><span class="normal"> </span><span class="symbol">();</span> |
| <span class="normal"> </span><span class="comment">// do stuff with self</span> |
| <span class="normal"> self</span><span class="symbol">-></span><span class="normal">idle_id </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span> |
| <span class="normal"> </span><span class="function"><a href="http://developer.gnome.org/gdk3/gdk3-Threads.html#GDK-THREADS-LEAVE:CAPS">GDK_THREADS_LEAVE</a></span><span class="normal"> </span><span class="symbol">();</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="keyword">return</span><span class="normal"> <a href="glib-The-Main-Event-Loop.html#G-SOURCE-REMOVE:CAPS">G_SOURCE_REMOVE</a></span><span class="symbol">;</span> |
| <span class="cbracket">}</span> |
| <span class="normal"> </span> |
| <span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span> |
| <span class="function">some_widget_do_stuff_later</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">SomeWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> self</span><span class="symbol">-></span><span class="normal">idle_id </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-idle-add">g_idle_add</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">idle_callback</span><span class="symbol">,</span><span class="normal"> self</span><span class="symbol">);</span> |
| <span class="cbracket">}</span> |
| <span class="normal"> </span> |
| <span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span> |
| <span class="function">some_widget_finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">GObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">object</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> </span><span class="usertype">SomeWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> </span><span class="function">SOME_WIDGET</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">self</span><span class="symbol">-></span><span class="normal">idle_id</span><span class="symbol">)</span> |
| <span class="normal"> </span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-source-remove">g_source_remove</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">self</span><span class="symbol">-></span><span class="normal">idle_id</span><span class="symbol">);</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="function"><a href="https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#G-OBJECT-CLASS:CAPS">G_OBJECT_CLASS</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">parent_class</span><span class="symbol">)-></span><span class="function">finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span> |
| <span class="cbracket">}</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p></p> |
| <p>This will fail in a multi-threaded application if the |
| widget is destroyed before the idle handler fires due |
| to the use after free in the callback. A solution, to |
| this particular problem, is to check to if the source |
| has already been destroy within the callback.</p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="glib-Basic-Types.html#gboolean">gboolean</a> </span> |
| <span class="function">idle_callback</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">gpointer</span><span class="normal"> data</span><span class="symbol">)</span> |
| <span class="cbracket">{</span> |
| <span class="normal"> </span><span class="usertype">SomeWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> data</span><span class="symbol">;</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="function"><a href="http://developer.gnome.org/gdk3/gdk3-Threads.html#GDK-THREADS-ENTER:CAPS">GDK_THREADS_ENTER</a></span><span class="normal"> </span><span class="symbol">();</span> |
| <span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-source-is-destroyed">g_source_is_destroyed</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-current-source">g_main_current_source</a></span><span class="normal"> </span><span class="symbol">()))</span> |
| <span class="normal"> </span><span class="cbracket">{</span> |
| <span class="normal"> </span><span class="comment">// do stuff with self</span> |
| <span class="normal"> </span><span class="cbracket">}</span> |
| <span class="normal"> </span><span class="function"><a href="http://developer.gnome.org/gdk3/gdk3-Threads.html#GDK-THREADS-LEAVE:CAPS">GDK_THREADS_LEAVE</a></span><span class="normal"> </span><span class="symbol">();</span> |
| <span class="normal"> </span> |
| <span class="normal"> </span><span class="keyword">return</span><span class="normal"> <a href="glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">;</span> |
| <span class="cbracket">}</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p></p> |
| <div class="refsect3"> |
| <a name="g-source-is-destroyed.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-is-destroyed.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the source has been destroyed</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-12.html#api-index-2.12">2.12</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-set-priority"></a><h3>g_source_set_priority ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_set_priority (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> priority</code></em>);</pre> |
| <p>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.</p> |
| <p>A child source always has the same priority as its parent. It is not |
| permitted to change the priority of a source once it has been added |
| as a child of another source.</p> |
| <div class="refsect3"> |
| <a name="g-source-set-priority.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>priority</p></td> |
| <td class="parameter_description"><p>the new priority.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-get-priority"></a><h3>g_source_get_priority ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a> |
| g_source_get_priority (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Gets the priority of a source.</p> |
| <div class="refsect3"> |
| <a name="g-source-get-priority.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-get-priority.returns"></a><h4>Returns</h4> |
| <p> the priority of the source</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-set-can-recurse"></a><h3>g_source_set_can_recurse ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_set_can_recurse (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> can_recurse</code></em>);</pre> |
| <p>Sets whether a source can be called recursively. If <em class="parameter"><code>can_recurse</code></em> |
| is |
| <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, then while the source is being dispatched then this source |
| will be processed normally. Otherwise, all processing of this |
| source is blocked until the dispatch function returns.</p> |
| <div class="refsect3"> |
| <a name="g-source-set-can-recurse.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>can_recurse</p></td> |
| <td class="parameter_description"><p>whether recursion is allowed for this source</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-get-can-recurse"></a><h3>g_source_get_can_recurse ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_source_get_can_recurse (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Checks whether a source is allowed to be called recursively. |
| see <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-can-recurse" title="g_source_set_can_recurse ()"><code class="function">g_source_set_can_recurse()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-source-get-can-recurse.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-get-can-recurse.returns"></a><h4>Returns</h4> |
| <p> whether recursion is allowed.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-get-id"></a><h3>g_source_get_id ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a> |
| g_source_get_id (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Returns the numeric ID for a particular source. The ID of a source |
| is a positive integer which is unique within a particular main loop |
| context. The reverse |
| mapping from ID to source is done by <a class="link" href="glib-The-Main-Event-Loop.html#g-main-context-find-source-by-id" title="g_main_context_find_source_by_id ()"><code class="function">g_main_context_find_source_by_id()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-source-get-id.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-get-id.returns"></a><h4>Returns</h4> |
| <p> the ID (greater than 0) for the source</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-get-name"></a><h3>g_source_get_name ()</h3> |
| <pre class="programlisting">const <span class="returnvalue">char</span> * |
| g_source_get_name (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Gets a name for the source, used in debugging and profiling. The |
| name may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><span class="type">NULL</span></a> if it has never been set with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-name" title="g_source_set_name ()"><code class="function">g_source_set_name()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-source-get-name.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-get-name.returns"></a><h4>Returns</h4> |
| <p> the name of the source</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-set-name"></a><h3>g_source_set_name ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_set_name (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code>const <span class="type">char</span> *name</code></em>);</pre> |
| <p>Sets a name for the source, used in debugging and profiling. |
| The name defaults to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><span class="type">NULL</span></a>.</p> |
| <p>The source name should describe in a human-readable way |
| what the source does. For example, "X11 event queue" |
| or "GTK+ repaint idle handler" or whatever it is.</p> |
| <p>It is permitted to call this function multiple times, but is not |
| recommended due to the potential performance impact. For example, |
| one could change the name in the "check" function of a <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> |
| to include details like the event type in the source name.</p> |
| <p>Use caution if changing the name while another thread may be |
| accessing it with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-name" title="g_source_get_name ()"><code class="function">g_source_get_name()</code></a>; that function does not copy |
| the value, and changing the value will free it while the other thread |
| may be attempting to use it.</p> |
| <div class="refsect3"> |
| <a name="g-source-set-name.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>name</p></td> |
| <td class="parameter_description"><p>debug name for the source</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-set-name-by-id"></a><h3>g_source_set_name_by_id ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_set_name_by_id (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> tag</code></em>, |
| <em class="parameter"><code>const <span class="type">char</span> *name</code></em>);</pre> |
| <p>Sets the name of a source using its ID.</p> |
| <p>This is a convenience utility to set source names from the return |
| value of <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>, etc.</p> |
| <p>It is a programmer error to attempt to set the name of a non-existent |
| source.</p> |
| <p>More specifically: source IDs can be reissued after a source has been |
| destroyed and therefore it is never valid to use this function with a |
| source ID which may have already been removed. An example is when |
| scheduling an idle to run in another thread with <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>: the |
| idle may already have run and been removed by the time this function |
| is called on its (now invalid) source ID. This source ID may have |
| been reissued, leading to the operation being performed against the |
| wrong source.</p> |
| <div class="refsect3"> |
| <a name="g-source-set-name-by-id.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>tag</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> ID</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>name</p></td> |
| <td class="parameter_description"><p>debug name for the source</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-get-context"></a><h3>g_source_get_context ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="returnvalue">GMainContext</span></a> * |
| g_source_get_context (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Gets the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> with which the source is associated.</p> |
| <p>You can call this on a source that has been destroyed, provided |
| that the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> it was attached to still exists (in which |
| case it will return that <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>). In particular, you can |
| always call this function on the source returned from |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-main-current-source" title="g_main_current_source ()"><code class="function">g_main_current_source()</code></a>. But calling this function on a source |
| whose <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> has been destroyed is an error.</p> |
| <div class="refsect3"> |
| <a name="g-source-get-context.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-get-context.returns"></a><h4>Returns</h4> |
| <p> the <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a> with which the |
| source is associated, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the context has not |
| yet been added to a source. </p> |
| <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>][<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-set-callback"></a><h3>g_source_set_callback ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_set_callback (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> func</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre> |
| <p>Sets the callback function for a source. The callback for a source is |
| called from the source's dispatch function.</p> |
| <p>The exact type of <em class="parameter"><code>func</code></em> |
| depends on the type of source; ie. you |
| should not count on <em class="parameter"><code>func</code></em> |
| being called with <em class="parameter"><code>data</code></em> |
| as its first |
| parameter.</p> |
| <p>See <a class="link" href="glib-The-Main-Event-Loop.html#mainloop-memory-management" title="Memory management of sources">memory management of sources</a> for details |
| on how to handle memory management of <em class="parameter"><code>data</code></em> |
| .</p> |
| <p>Typically, you won't use this function. Instead use functions specific |
| to the type of source you are using.</p> |
| <div class="refsect3"> |
| <a name="g-source-set-callback.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>the source</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>func</p></td> |
| <td class="parameter_description"><p>a callback function</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>data</p></td> |
| <td class="parameter_description"><p>the data to pass to callback function</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>notify</p></td> |
| <td class="parameter_description"><p> a function to call when <em class="parameter"><code>data</code></em> |
| is no longer in use, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSourceFunc"></a><h3>GSourceFunc ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| <span class="c_punctuation">(</span>*GSourceFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre> |
| <p>Specifies the type of function passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>, |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-full" title="g_timeout_add_full ()"><code class="function">g_timeout_add_full()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>, and <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add-full" title="g_idle_add_full ()"><code class="function">g_idle_add_full()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="GSourceFunc.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>user_data</p></td> |
| <td class="parameter_description"><p>data passed to the function, set when the source was |
| created with one of the above functions</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="GSourceFunc.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> if the source should be removed. <a class="link" href="glib-The-Main-Event-Loop.html#G-SOURCE-CONTINUE:CAPS" title="G_SOURCE_CONTINUE"><span class="type">G_SOURCE_CONTINUE</span></a> and |
| <a class="link" href="glib-The-Main-Event-Loop.html#G-SOURCE-REMOVE:CAPS" title="G_SOURCE_REMOVE"><span class="type">G_SOURCE_REMOVE</span></a> are more memorable names for the return value.</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-set-callback-indirect"></a><h3>g_source_set_callback_indirect ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_set_callback_indirect (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> callback_data</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceCallbackFuncs" title="struct GSourceCallbackFuncs"><span class="type">GSourceCallbackFuncs</span></a> *callback_funcs</code></em>);</pre> |
| <p>Sets the callback function storing the data as a refcounted callback |
| "object". This is used internally. Note that calling |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-callback-indirect" title="g_source_set_callback_indirect ()"><code class="function">g_source_set_callback_indirect()</code></a> assumes |
| an initial reference count on <em class="parameter"><code>callback_data</code></em> |
| , and thus |
| <em class="parameter"><code>callback_funcs->unref</code></em> |
| will eventually be called once more |
| than <em class="parameter"><code>callback_funcs->ref</code></em> |
| .</p> |
| <div class="refsect3"> |
| <a name="g-source-set-callback-indirect.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>the source</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>callback_data</p></td> |
| <td class="parameter_description"><p>pointer to callback data "object"</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>callback_funcs</p></td> |
| <td class="parameter_description"><p>functions for reference counting <em class="parameter"><code>callback_data</code></em> |
| and getting the callback and data</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-set-ready-time"></a><h3>g_source_set_ready_time ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_set_ready_time (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="type">gint64</span></a> ready_time</code></em>);</pre> |
| <p>Sets a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> to be dispatched when the given monotonic time is |
| reached (or passed). If the monotonic time is in the past (as it |
| always will be if <em class="parameter"><code>ready_time</code></em> |
| is 0) then the source will be |
| dispatched immediately.</p> |
| <p>If <em class="parameter"><code>ready_time</code></em> |
| is -1 then the source is never woken up on the basis |
| of the passage of time.</p> |
| <p>Dispatching the source does not reset the ready time. You should do |
| so yourself, from the source dispatch function.</p> |
| <p>Note that if you have a pair of sources where the ready time of one |
| suggests that it will be delivered first but the priority for the |
| other suggests that it would be delivered first, and the ready time |
| for both sources is reached during the same main context iteration |
| then the order of dispatch is undefined.</p> |
| <p>This API is only intended to be used by implementations of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. |
| Do not call this API on a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that you did not create.</p> |
| <div class="refsect3"> |
| <a name="g-source-set-ready-time.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>ready_time</p></td> |
| <td class="parameter_description"><p>the monotonic time at which the source will be ready, |
| 0 for "immediately", -1 for "never"</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-36.html#api-index-2.36">2.36</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-get-ready-time"></a><h3>g_source_get_ready_time ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="returnvalue">gint64</span></a> |
| g_source_get_ready_time (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Gets the "ready time" of <em class="parameter"><code>source</code></em> |
| , as set by |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-ready-time" title="g_source_set_ready_time ()"><code class="function">g_source_set_ready_time()</code></a>.</p> |
| <p>Any time before the current monotonic time (including 0) is an |
| indication that the source will fire immediately.</p> |
| <div class="refsect3"> |
| <a name="g-source-get-ready-time.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-get-ready-time.returns"></a><h4>Returns</h4> |
| <p> the monotonic ready time, -1 for "never"</p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-add-unix-fd"></a><h3>g_source_add_unix_fd ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> |
| g_source_add_unix_fd (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> fd</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-IO-Channels.html#GIOCondition" title="enum GIOCondition"><span class="type">GIOCondition</span></a> events</code></em>);</pre> |
| <p>Monitors <em class="parameter"><code>fd</code></em> |
| for the IO events in <em class="parameter"><code>events</code></em> |
| .</p> |
| <p>The tag returned by this function can be used to remove or modify the |
| monitoring of the fd using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-unix-fd" title="g_source_remove_unix_fd ()"><code class="function">g_source_remove_unix_fd()</code></a> or |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-modify-unix-fd" title="g_source_modify_unix_fd ()"><code class="function">g_source_modify_unix_fd()</code></a>.</p> |
| <p>It is not necessary to remove the fd before destroying the source; it |
| will be cleaned up automatically.</p> |
| <p>This API is only intended to be used by implementations of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. |
| Do not call this API on a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that you did not create.</p> |
| <p>As the name suggests, this function is not available on Windows.</p> |
| <div class="refsect3"> |
| <a name="g-source-add-unix-fd.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>fd</p></td> |
| <td class="parameter_description"><p>the fd to monitor</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>events</p></td> |
| <td class="parameter_description"><p>an event mask</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-add-unix-fd.returns"></a><h4>Returns</h4> |
| <p> an opaque tag. </p> |
| <p><span class="annotation">[<acronym title="NULL must not be passed as the value in, out, in-out; or as a return value."><span class="acronym">not nullable</span></acronym>]</span></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-36.html#api-index-2.36">2.36</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-remove-unix-fd"></a><h3>g_source_remove_unix_fd ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_remove_unix_fd (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> tag</code></em>);</pre> |
| <p>Reverses the effect of a previous call to <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-unix-fd" title="g_source_add_unix_fd ()"><code class="function">g_source_add_unix_fd()</code></a>.</p> |
| <p>You only need to call this if you want to remove an fd from being |
| watched while keeping the same source around. In the normal case you |
| will just want to destroy the source.</p> |
| <p>This API is only intended to be used by implementations of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. |
| Do not call this API on a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that you did not create.</p> |
| <p>As the name suggests, this function is not available on Windows.</p> |
| <div class="refsect3"> |
| <a name="g-source-remove-unix-fd.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>tag</p></td> |
| <td class="parameter_description"><p> the tag from <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-unix-fd" title="g_source_add_unix_fd ()"><code class="function">g_source_add_unix_fd()</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL must not be passed as the value in, out, in-out; or as a return value."><span class="acronym">not nullable</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-36.html#api-index-2.36">2.36</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-modify-unix-fd"></a><h3>g_source_modify_unix_fd ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_modify_unix_fd (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> tag</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-IO-Channels.html#GIOCondition" title="enum GIOCondition"><span class="type">GIOCondition</span></a> new_events</code></em>);</pre> |
| <p>Updates the event mask to watch for the fd identified by <em class="parameter"><code>tag</code></em> |
| .</p> |
| <p><em class="parameter"><code>tag</code></em> |
| is the tag returned from <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-unix-fd" title="g_source_add_unix_fd ()"><code class="function">g_source_add_unix_fd()</code></a>.</p> |
| <p>If you want to remove a fd, don't set its event mask to zero. |
| Instead, call <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-unix-fd" title="g_source_remove_unix_fd ()"><code class="function">g_source_remove_unix_fd()</code></a>.</p> |
| <p>This API is only intended to be used by implementations of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. |
| Do not call this API on a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that you did not create.</p> |
| <p>As the name suggests, this function is not available on Windows.</p> |
| <div class="refsect3"> |
| <a name="g-source-modify-unix-fd.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>tag</p></td> |
| <td class="parameter_description"><p> the tag from <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-unix-fd" title="g_source_add_unix_fd ()"><code class="function">g_source_add_unix_fd()</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL must not be passed as the value in, out, in-out; or as a return value."><span class="acronym">not nullable</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>new_events</p></td> |
| <td class="parameter_description"><p>the new event mask to watch</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-36.html#api-index-2.36">2.36</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-query-unix-fd"></a><h3>g_source_query_unix_fd ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-IO-Channels.html#GIOCondition" title="enum GIOCondition"><span class="returnvalue">GIOCondition</span></a> |
| g_source_query_unix_fd (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> tag</code></em>);</pre> |
| <p>Queries the events reported for the fd corresponding to <em class="parameter"><code>tag</code></em> |
| on |
| <em class="parameter"><code>source</code></em> |
| during the last poll.</p> |
| <p>The return value of this function is only defined when the function |
| is called from the check or dispatch functions for <em class="parameter"><code>source</code></em> |
| .</p> |
| <p>This API is only intended to be used by implementations of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. |
| Do not call this API on a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that you did not create.</p> |
| <p>As the name suggests, this function is not available on Windows.</p> |
| <div class="refsect3"> |
| <a name="g-source-query-unix-fd.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>tag</p></td> |
| <td class="parameter_description"><p> the tag from <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-unix-fd" title="g_source_add_unix_fd ()"><code class="function">g_source_add_unix_fd()</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL must not be passed as the value in, out, in-out; or as a return value."><span class="acronym">not nullable</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-query-unix-fd.returns"></a><h4>Returns</h4> |
| <p> the conditions reported on the fd</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-36.html#api-index-2.36">2.36</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-add-poll"></a><h3>g_source_add_poll ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_add_poll (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);</pre> |
| <p>Adds a file descriptor to the set of file descriptors polled for |
| this source. This is usually combined with <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()"><code class="function">g_source_new()</code></a> to add an |
| event source. The event source's check function will typically test |
| the <em class="parameter"><code>revents</code></em> |
| field in the <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> struct and return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if events need |
| to be processed.</p> |
| <p>This API is only intended to be used by implementations of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. |
| Do not call this API on a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that you did not create.</p> |
| <p>Using this API forces the linear scanning of event sources on each |
| main loop iteration. Newly-written event sources should try to use |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-unix-fd" title="g_source_add_unix_fd ()"><code class="function">g_source_add_unix_fd()</code></a> instead of this API.</p> |
| <div class="refsect3"> |
| <a name="g-source-add-poll.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>fd</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> structure holding information about a file |
| descriptor to watch.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-remove-poll"></a><h3>g_source_remove_poll ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_remove_poll (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> *fd</code></em>);</pre> |
| <p>Removes a file descriptor from the set of file descriptors polled for |
| this source. </p> |
| <p>This API is only intended to be used by implementations of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. |
| Do not call this API on a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that you did not create.</p> |
| <div class="refsect3"> |
| <a name="g-source-remove-poll.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>fd</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a> structure previously passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-poll" title="g_source_add_poll ()"><code class="function">g_source_add_poll()</code></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-add-child-source"></a><h3>g_source_add_child_source ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_add_child_source (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *child_source</code></em>);</pre> |
| <p>Adds <em class="parameter"><code>child_source</code></em> |
| to <em class="parameter"><code>source</code></em> |
| as a "polled" source; when <em class="parameter"><code>source</code></em> |
| is |
| added to a <a class="link" href="glib-The-Main-Event-Loop.html#GMainContext" title="GMainContext"><span class="type">GMainContext</span></a>, <em class="parameter"><code>child_source</code></em> |
| will be automatically added |
| with the same priority, when <em class="parameter"><code>child_source</code></em> |
| is triggered, it will |
| cause <em class="parameter"><code>source</code></em> |
| to dispatch (in addition to calling its own |
| callback), and when <em class="parameter"><code>source</code></em> |
| is destroyed, it will destroy |
| <em class="parameter"><code>child_source</code></em> |
| as well. (<em class="parameter"><code>source</code></em> |
| will also still be dispatched if |
| its own prepare/check functions indicate that it is ready.)</p> |
| <p>If you don't need <em class="parameter"><code>child_source</code></em> |
| to do anything on its own when it |
| triggers, you can call <a href="https://developer.gnome.org/gobject/unstable/gobject-Closures.html#g-source-set-dummy-callback"><code class="function">g_source_set_dummy_callback()</code></a> on it to set a |
| callback that does nothing (except return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if appropriate).</p> |
| <p><em class="parameter"><code>source</code></em> |
| will hold a reference on <em class="parameter"><code>child_source</code></em> |
| while <em class="parameter"><code>child_source</code></em> |
| |
| is attached to it.</p> |
| <p>This API is only intended to be used by implementations of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. |
| Do not call this API on a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that you did not create.</p> |
| <div class="refsect3"> |
| <a name="g-source-add-child-source.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>child_source</p></td> |
| <td class="parameter_description"><p>a second <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that <em class="parameter"><code>source</code></em> |
| should "poll"</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-28.html#api-index-2.28">2.28</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-remove-child-source"></a><h3>g_source_remove_child_source ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_remove_child_source (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *child_source</code></em>);</pre> |
| <p>Detaches <em class="parameter"><code>child_source</code></em> |
| from <em class="parameter"><code>source</code></em> |
| and destroys it.</p> |
| <p>This API is only intended to be used by implementations of <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>. |
| Do not call this API on a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> that you did not create.</p> |
| <div class="refsect3"> |
| <a name="g-source-remove-child-source.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>child_source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> previously passed to |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-child-source" title="g_source_add_child_source ()"><code class="function">g_source_add_child_source()</code></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-28.html#api-index-2.28">2.28</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-get-time"></a><h3>g_source_get_time ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="returnvalue">gint64</span></a> |
| g_source_get_time (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>);</pre> |
| <p>Gets the time to be used when checking this source. The advantage of |
| calling this function over calling <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a> directly is |
| that when checking multiple sources, GLib can cache a single value |
| instead of having to repeatedly get the system monotonic time.</p> |
| <p>The time here is the system monotonic time, if available, or some |
| other reasonable alternative otherwise. See <a class="link" href="glib-Date-and-Time-Functions.html#g-get-monotonic-time" title="g_get_monotonic_time ()"><code class="function">g_get_monotonic_time()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-source-get-time.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-get-time.returns"></a><h4>Returns</h4> |
| <p> the monotonic time in microseconds</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-28.html#api-index-2.28">2.28</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-get-current-time"></a><h3>g_source_get_current_time ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_source_get_current_time (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> *source</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="struct GTimeVal"><span class="type">GTimeVal</span></a> *timeval</code></em>);</pre> |
| <div class="warning"> |
| <p><code class="literal">g_source_get_current_time</code> has been deprecated since version 2.28 and should not be used in newly-written code.</p> |
| <p>use <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-time" title="g_source_get_time ()"><code class="function">g_source_get_time()</code></a> instead</p> |
| </div> |
| <p>This function ignores <em class="parameter"><code>source</code></em> |
| and is otherwise the same as |
| <a class="link" href="glib-Date-and-Time-Functions.html#g-get-current-time" title="g_get_current_time ()"><code class="function">g_get_current_time()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-source-get-current-time.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>source</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>timeval</p></td> |
| <td class="parameter_description"><p><a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="struct GTimeVal"><span class="type">GTimeVal</span></a> structure in which to store current time.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-remove"></a><h3>g_source_remove ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_source_remove (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> tag</code></em>);</pre> |
| <p>Removes the source with the given id from the default main context.</p> |
| <p>The id of a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> is given by <a class="link" href="glib-The-Main-Event-Loop.html#g-source-get-id" title="g_source_get_id ()"><code class="function">g_source_get_id()</code></a>, or will be |
| returned by the functions <a class="link" href="glib-The-Main-Event-Loop.html#g-source-attach" title="g_source_attach ()"><code class="function">g_source_attach()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>, |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add-full" title="g_idle_add_full ()"><code class="function">g_idle_add_full()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add-full" title="g_timeout_add_full ()"><code class="function">g_timeout_add_full()</code></a>, |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add" title="g_child_watch_add ()"><code class="function">g_child_watch_add()</code></a>, <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add-full" title="g_child_watch_add_full ()"><code class="function">g_child_watch_add_full()</code></a>, <a class="link" href="glib-IO-Channels.html#g-io-add-watch" title="g_io_add_watch ()"><code class="function">g_io_add_watch()</code></a>, and |
| <a class="link" href="glib-IO-Channels.html#g-io-add-watch-full" title="g_io_add_watch_full ()"><code class="function">g_io_add_watch_full()</code></a>.</p> |
| <p>See also <a class="link" href="glib-The-Main-Event-Loop.html#g-source-destroy" title="g_source_destroy ()"><code class="function">g_source_destroy()</code></a>. You must use <a class="link" href="glib-The-Main-Event-Loop.html#g-source-destroy" title="g_source_destroy ()"><code class="function">g_source_destroy()</code></a> for sources |
| added to a non-default main context.</p> |
| <p>It is a programmer error to attempt to remove a non-existent source.</p> |
| <p>More specifically: source IDs can be reissued after a source has been |
| destroyed and therefore it is never valid to use this function with a |
| source ID which may have already been removed. An example is when |
| scheduling an idle to run in another thread with <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>: the |
| idle may already have run and been removed by the time this function |
| is called on its (now invalid) source ID. This source ID may have |
| been reissued, leading to the operation being performed against the |
| wrong source.</p> |
| <div class="refsect3"> |
| <a name="g-source-remove.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>tag</p></td> |
| <td class="parameter_description"><p>the ID of the source to remove.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-remove.returns"></a><h4>Returns</h4> |
| <p> For historical reasons, this function always returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a></p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-remove-by-funcs-user-data"></a><h3>g_source_remove_by_funcs_user_data ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_source_remove_by_funcs_user_data (<em class="parameter"><code><a class="link" href="glib-The-Main-Event-Loop.html#GSourceFuncs" title="struct GSourceFuncs"><span class="type">GSourceFuncs</span></a> *funcs</code></em>, |
| <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre> |
| <p>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.</p> |
| <div class="refsect3"> |
| <a name="g-source-remove-by-funcs-user-data.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>funcs</p></td> |
| <td class="parameter_description"><p>The <em class="parameter"><code>source_funcs</code></em> |
| passed to <a class="link" href="glib-The-Main-Event-Loop.html#g-source-new" title="g_source_new ()"><code class="function">g_source_new()</code></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>user_data</p></td> |
| <td class="parameter_description"><p>the user data for the callback</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-remove-by-funcs-user-data.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if a source was found and removed. </p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-source-remove-by-user-data"></a><h3>g_source_remove_by_user_data ()</h3> |
| <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> |
| g_source_remove_by_user_data (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre> |
| <p>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.</p> |
| <div class="refsect3"> |
| <a name="g-source-remove-by-user-data.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>user_data</p></td> |
| <td class="parameter_description"><p>the user_data for the callback.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-source-remove-by-user-data.returns"></a><h4>Returns</h4> |
| <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if a source was found and removed. </p> |
| </div> |
| </div> |
| </div> |
| <div class="refsect1"> |
| <a name="glib-The-Main-Event-Loop.other_details"></a><h2>Types and Values</h2> |
| <div class="refsect2"> |
| <a name="GMainLoop"></a><h3>GMainLoop</h3> |
| <pre class="programlisting">typedef struct _GMainLoop GMainLoop;</pre> |
| <p>The <code class="literal">GMainLoop</code> struct is an opaque data type |
| representing the main event loop of a GLib or GTK+ application.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="G-PRIORITY-HIGH:CAPS"></a><h3>G_PRIORITY_HIGH</h3> |
| <pre class="programlisting">#define G_PRIORITY_HIGH -100 |
| </pre> |
| <p>Use this for high priority event sources.</p> |
| <p>It is not used within GLib or GTK+.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="G-PRIORITY-DEFAULT:CAPS"></a><h3>G_PRIORITY_DEFAULT</h3> |
| <pre class="programlisting">#define G_PRIORITY_DEFAULT 0 |
| </pre> |
| <p>Use this for default priority event sources.</p> |
| <p>In GLib this priority is used when adding timeout functions |
| with <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add" title="g_timeout_add ()"><code class="function">g_timeout_add()</code></a>. In GDK this priority is used for events |
| from the X server.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="G-PRIORITY-HIGH-IDLE:CAPS"></a><h3>G_PRIORITY_HIGH_IDLE</h3> |
| <pre class="programlisting">#define G_PRIORITY_HIGH_IDLE 100 |
| </pre> |
| <p>Use this for high priority idle functions.</p> |
| <p>GTK+ uses <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE"><span class="type">G_PRIORITY_HIGH_IDLE</span></a> + 10 for resizing operations, |
| and <a class="link" href="glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS" title="G_PRIORITY_HIGH_IDLE"><span class="type">G_PRIORITY_HIGH_IDLE</span></a> + 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.)</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="G-PRIORITY-DEFAULT-IDLE:CAPS"></a><h3>G_PRIORITY_DEFAULT_IDLE</h3> |
| <pre class="programlisting">#define G_PRIORITY_DEFAULT_IDLE 200 |
| </pre> |
| <p>Use this for default priority idle functions.</p> |
| <p>In GLib this priority is used when adding idle functions with |
| <a class="link" href="glib-The-Main-Event-Loop.html#g-idle-add" title="g_idle_add ()"><code class="function">g_idle_add()</code></a>.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="G-PRIORITY-LOW:CAPS"></a><h3>G_PRIORITY_LOW</h3> |
| <pre class="programlisting">#define G_PRIORITY_LOW 300 |
| </pre> |
| <p>Use this for very low priority background tasks.</p> |
| <p>It is not used within GLib or GTK+.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="G-SOURCE-CONTINUE:CAPS"></a><h3>G_SOURCE_CONTINUE</h3> |
| <pre class="programlisting">#define G_SOURCE_CONTINUE TRUE |
| </pre> |
| <p>Use this macro as the return value of a <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> to leave |
| the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> in the main loop.</p> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="G-SOURCE-REMOVE:CAPS"></a><h3>G_SOURCE_REMOVE</h3> |
| <pre class="programlisting">#define G_SOURCE_REMOVE FALSE |
| </pre> |
| <p>Use this macro as the return value of a <a class="link" href="glib-The-Main-Event-Loop.html#GSourceFunc" title="GSourceFunc ()"><span class="type">GSourceFunc</span></a> to remove |
| the <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a> from the main loop.</p> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GMainContext"></a><h3>GMainContext</h3> |
| <pre class="programlisting">typedef struct _GMainContext GMainContext;</pre> |
| <p>The <code class="literal">GMainContext</code> struct is an opaque data |
| type representing a set of sources to be handled in a main loop.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GPid"></a><h3>GPid</h3> |
| <pre class="programlisting">typedef int GPid; |
| </pre> |
| <p>A type which is used to hold a process identification.</p> |
| <p>On UNIX, processes are identified by a process id (an integer), |
| while Windows uses process handles (which are pointers).</p> |
| <p>GPid is used in GLib only for descendant processes spawned with |
| the g_spawn functions.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="G-PID-FORMAT:CAPS"></a><h3>G_PID_FORMAT</h3> |
| <pre class="programlisting">#define G_PID_FORMAT "i" |
| </pre> |
| <p>A format specifier that can be used in <code class="function">printf()</code>-style format strings |
| when printing a <a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="type">GPid</span></a>.</p> |
| <p class="since">Since: <a class="link" href="api-index-2-50.html#api-index-2.50">2.50</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GPollFD"></a><h3>struct GPollFD</h3> |
| <pre class="programlisting">struct GPollFD { |
| #if defined (G_OS_WIN32) && GLIB_SIZEOF_VOID_P == 8 |
| #endif |
| #else |
| gint fd; |
| #endif |
| gushort events; |
| gushort revents; |
| }; |
| </pre> |
| <p>Represents a file descriptor, which events to poll for, and which events |
| occurred.</p> |
| <div class="refsect3"> |
| <a name="GPollFD.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="struct_members_name"> |
| <col class="struct_members_description"> |
| <col width="200px" class="struct_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="struct_member_name"><p><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> <em class="structfield"><code><a name="GPollFD.fd"></a>fd</code></em>;</p></td> |
| <td class="struct_member_description"><p>the file descriptor to poll (or a HANDLE on Win32)</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a class="link" href="glib-Basic-Types.html#gushort" title="gushort"><span class="type">gushort</span></a> <em class="structfield"><code><a name="GPollFD.events"></a>events</code></em>;</p></td> |
| <td class="struct_member_description"><p>a bitwise combination from <a class="link" href="glib-IO-Channels.html#GIOCondition" title="enum GIOCondition"><span class="type">GIOCondition</span></a>, specifying which |
| events should be polled for. Typically for reading from a file |
| descriptor you would use <a class="link" href="glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</code></a> | <a class="link" href="glib-IO-Channels.html#G-IO-HUP:CAPS"><code class="literal">G_IO_HUP</code></a> | <a class="link" href="glib-IO-Channels.html#G-IO-ERR:CAPS"><code class="literal">G_IO_ERR</code></a>, and |
| for writing you would use <a class="link" href="glib-IO-Channels.html#G-IO-OUT:CAPS"><code class="literal">G_IO_OUT</code></a> | <a class="link" href="glib-IO-Channels.html#G-IO-ERR:CAPS"><code class="literal">G_IO_ERR</code></a>.</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a class="link" href="glib-Basic-Types.html#gushort" title="gushort"><span class="type">gushort</span></a> <em class="structfield"><code><a name="GPollFD.revents"></a>revents</code></em>;</p></td> |
| <td class="struct_member_description"><p>a bitwise combination of flags from <a class="link" href="glib-IO-Channels.html#GIOCondition" title="enum GIOCondition"><span class="type">GIOCondition</span></a>, returned |
| from the <code class="function">poll()</code> function to indicate which events occurred.</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="G-POLLFD-FORMAT:CAPS"></a><h3>G_POLLFD_FORMAT</h3> |
| <pre class="programlisting">#define G_POLLFD_FORMAT "%d" |
| </pre> |
| <p>A format specifier that can be used in <code class="function">printf()</code>-style format strings |
| when printing the <em class="parameter"><code>fd</code></em> |
| member of a <a class="link" href="glib-The-Main-Event-Loop.html#GPollFD" title="struct GPollFD"><span class="type">GPollFD</span></a>.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSource"></a><h3>struct GSource</h3> |
| <pre class="programlisting">struct GSource { |
| }; |
| </pre> |
| <p>The <code class="literal">GSource</code> struct is an opaque data type |
| representing an event source.</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSourceFuncs"></a><h3>struct GSourceFuncs</h3> |
| <pre class="programlisting">struct GSourceFuncs { |
| 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 */ |
| }; |
| </pre> |
| <p>The <code class="literal">GSourceFuncs</code> struct contains a table of |
| functions used to handle event sources in a generic manner.</p> |
| <p>For idle sources, the prepare and check functions always return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> |
| to indicate that the source is always ready to be processed. The prepare |
| function also returns a timeout value of 0 to ensure that the <code class="function">poll()</code> call |
| doesn't block (since that would be time wasted which could have been spent |
| running the idle function).</p> |
| <p>For timeout sources, the prepare and check functions both return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> |
| if the timeout interval has expired. The prepare function also returns |
| a timeout value to ensure that the <code class="function">poll()</code> call doesn't block too long |
| and miss the next timeout.</p> |
| <p>For file descriptor sources, the prepare function typically returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, |
| since it must wait until <code class="function">poll()</code> has been called before it knows whether |
| any events need to be processed. It sets the returned timeout to -1 to |
| indicate that it doesn't mind how long the <code class="function">poll()</code> call blocks. In the |
| check function, it tests the results of the <code class="function">poll()</code> call to see if the |
| required condition has been met, and returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if so.</p> |
| <div class="refsect3"> |
| <a name="GSourceFuncs.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="struct_members_name"> |
| <col class="struct_members_description"> |
| <col width="200px" class="struct_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="struct_member_name"><p><em class="structfield"><code><a name="GSourceFuncs.prepare"></a>prepare</code></em> ()</p></td> |
| <td class="struct_member_description"><p>Called before all the file descriptors are polled. If the |
| source can determine that it is ready here (without waiting for the |
| results of the <code class="function">poll()</code> call) it should return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>. It can also return |
| a <em class="parameter"><code>timeout_</code></em> |
| value which should be the maximum timeout (in milliseconds) |
| which should be passed to the <code class="function">poll()</code> call. The actual timeout used will |
| be -1 if all sources returned -1, or it will be the minimum of all |
| the <em class="parameter"><code>timeout_</code></em> |
| values returned which were >= 0. Since 2.36 this may |
| be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, in which case the effect is as if the function always returns |
| <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> with a timeout of -1. If <em class="parameter"><code>prepare</code></em> |
| returns a |
| timeout and the source also has a 'ready time' set then the |
| nearer of the two will be used.</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><em class="structfield"><code><a name="GSourceFuncs.check"></a>check</code></em> ()</p></td> |
| <td class="struct_member_description"><p>Called after all the file descriptors are polled. The source |
| should return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if it is ready to be dispatched. Note that some |
| time may have passed since the previous prepare function was called, |
| so the source should be checked again here. Since 2.36 this may |
| be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, in which case the effect is as if the function always returns |
| <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>.</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><em class="structfield"><code><a name="GSourceFuncs.dispatch"></a>dispatch</code></em> ()</p></td> |
| <td class="struct_member_description"><p>Called to dispatch the event source, after it has returned |
| <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> in either its <em class="parameter"><code>prepare</code></em> |
| or its <em class="parameter"><code>check</code></em> |
| function. The <em class="parameter"><code>dispatch</code></em> |
| function is passed in a callback function and data. The callback |
| function may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the source was never connected to a callback |
| using <a class="link" href="glib-The-Main-Event-Loop.html#g-source-set-callback" title="g_source_set_callback ()"><code class="function">g_source_set_callback()</code></a>. The <em class="parameter"><code>dispatch</code></em> |
| function should call the |
| callback function with <em class="parameter"><code>user_data</code></em> |
| and whatever additional parameters |
| are needed for this type of event source. The return value of the |
| <em class="parameter"><code>dispatch</code></em> |
| function should be <a class="link" href="glib-The-Main-Event-Loop.html#G-SOURCE-REMOVE:CAPS" title="G_SOURCE_REMOVE"><span class="type">G_SOURCE_REMOVE</span></a> if the source should be |
| removed or <a class="link" href="glib-The-Main-Event-Loop.html#G-SOURCE-CONTINUE:CAPS" title="G_SOURCE_CONTINUE"><span class="type">G_SOURCE_CONTINUE</span></a> to keep it.</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><em class="structfield"><code><a name="GSourceFuncs.finalize"></a>finalize</code></em> ()</p></td> |
| <td class="struct_member_description"><p>Called when the source is finalized.</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSourceCallbackFuncs"></a><h3>struct GSourceCallbackFuncs</h3> |
| <pre class="programlisting">struct GSourceCallbackFuncs { |
| void (*ref) (gpointer cb_data); |
| void (*unref) (gpointer cb_data); |
| void (*get) (gpointer cb_data, |
| GSource *source, |
| GSourceFunc *func, |
| gpointer *data); |
| }; |
| </pre> |
| <p>The <code class="literal">GSourceCallbackFuncs</code> struct contains |
| functions for managing callback objects.</p> |
| <div class="refsect3"> |
| <a name="GSourceCallbackFuncs.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="struct_members_name"> |
| <col class="struct_members_description"> |
| <col width="200px" class="struct_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="struct_member_name"><p><em class="structfield"><code><a name="GSourceCallbackFuncs.ref"></a>ref</code></em> ()</p></td> |
| <td class="struct_member_description"><p>Called when a reference is added to the callback object</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><em class="structfield"><code><a name="GSourceCallbackFuncs.unref"></a>unref</code></em> ()</p></td> |
| <td class="struct_member_description"><p>Called when a reference to the callback object is dropped</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><em class="structfield"><code><a name="GSourceCallbackFuncs.get"></a>get</code></em> ()</p></td> |
| <td class="struct_member_description"><p>Called to extract the callback function and data from the |
| callback object.</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="footer"> |
| <hr>Generated by GTK-Doc V1.25.1</div> |
| </body> |
| </html> |