📄 glib-the-main-event-loop.html
字号:
<hr><div class="refsect2" lang="en"><a name="id2849953"></a><h3><a name="G-PRIORITY-LOW:CAPS"></a>G_PRIORITY_LOW</h3><a class="indexterm" name="id2849963"></a><pre class="programlisting">#define G_PRIORITY_LOW 300</pre><p>Use this for very low priority background tasks.It is not used within GLib or GTK+.</p></div><hr><div class="refsect2" lang="en"><a name="id2849980"></a><h3><a name="GMainContext"></a>GMainContext</h3><a class="indexterm" name="id2849991"></a><pre class="programlisting">typedef struct _GMainContext GMainContext;</pre><p>The <span class="structname">GMainContext</span> struct is an opaque data type representing a set of sources to be handled in a main loop. </p></div><hr><div class="refsect2" lang="en"><a name="id2850012"></a><h3><a name="g-main-context-new"></a>g_main_context_new ()</h3><a class="indexterm" name="id2850022"></a><pre class="programlisting"><a href="glib-The-Main-Event-Loop.html#GMainContext">GMainContext</a>* g_main_context_new (void);</pre><p>Creates a new <a href="glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a> strcuture</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the new <a href="glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2850078"></a><h3><a name="g-main-context-ref"></a>g_main_context_ref ()</h3><a class="indexterm" name="id2850089"></a><pre class="programlisting"><a href="glib-The-Main-Event-Loop.html#GMainContext">GMainContext</a>* g_main_context_ref (<a href="glib-The-Main-Event-Loop.html#GMainContext">GMainContext</a> *context);</pre><p>Increases the reference count on a <a href="glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a> object by one.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>context</code></em> :</span></td><td> a <a href="glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the <em class="parameter"><code>context</code></em> that was passed in (since 2.6)</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2850172"></a><h3><a name="g-main-context-unref"></a>g_main_context_unref ()</h3><a class="indexterm" name="id2850183"></a><pre class="programlisting">void g_main_context_unref (<a href="glib-The-Main-Event-Loop.html#GMainContext">GMainContext</a> *context);</pre><p>Decreases the reference count on a <a href="glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a> object by one. Ifthe result is zero, free the context and free all associated memory.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>context</code></em> :</span></td><td> a <a href="glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2850251"></a><h3><a name="g-main-context-default"></a>g_main_context_default ()</h3><a class="indexterm" name="id2850262"></a><pre class="programlisting"><a href="glib-The-Main-Event-Loop.html#GMainContext">GMainContext</a>* g_main_context_default (void);</pre><p>Returns the default main context. This is the main context usedfor main loop functions when a main loop is not explicitlyspecified.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the default main context.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2850304"></a><h3><a name="g-main-context-iteration"></a>g_main_context_iteration ()</h3><a class="indexterm" name="id2850315"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_main_context_iteration (<a href="glib-The-Main-Event-Loop.html#GMainContext">GMainContext</a> *context, <a href="glib-Basic-Types.html#gboolean">gboolean</a> may_block);</pre><p>Runs a single iteration for the given main loop. This involveschecking 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 <code class="literal">TRUE</code>, waitingfor a source to become ready, then dispatching the highest priorityevents sources that are ready. Note that even when <em class="parameter"><code>may_block</code></em> is <code class="literal">TRUE</code>,it is still possible for <a href="glib-The-Main-Event-Loop.html#g-main-context-iteration"><code class="function">g_main_context_iteration()</code></a> to return<code class="literal">FALSE</code>, since the the wait may be interrupted for otherreasons than an event source becoming ready.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>context</code></em> :</span></td><td> a <a href="glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a> (if <code class="literal">NULL</code>, the default context will be used) </td></tr><tr><td><span class="term"><em class="parameter"><code>may_block</code></em> :</span></td><td> whether the call may block.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">TRUE</code> if events were dispatched.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2850466"></a><h3><a name="g-main-iteration"></a>g_main_iteration()</h3><a class="indexterm" name="id2850476"></a><pre class="programlisting">#define g_main_iteration(may_block)</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">g_main_iteration</code> is deprecated and should not be used in newly-written code. Use <a href="glib-The-Main-Event-Loop.html#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 href="glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>may_block</code></em> :</span></td><td>set to <code class="literal">TRUE</code> if it should block (i.e. wait) until an event sourcebecomes ready. It will return after an event source has been processed.If set to <code class="literal">FALSE</code> it will return immediately if no event source is ready to beprocessed.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><code class="literal">TRUE</code> if more events are pending.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2850573"></a><h3><a name="g-main-context-pending"></a>g_main_context_pending ()</h3><a class="indexterm" name="id2850584"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_main_context_pending (<a href="glib-The-Main-Event-Loop.html#GMainContext">GMainContext</a> *context);</pre><p>Checks if any sources have pending events for the given context.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>context</code></em> :</span></td><td> a <a href="glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a> (if <code class="literal">NULL</code>, the default context will be used)</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">TRUE</code> if events are pending.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2850666"></a><h3><a name="g-main-pending"></a>g_main_pending()</h3><a class="indexterm" name="id2850677"></a><pre class="programlisting">#define g_main_pending()</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">g_main_pending</code> is deprecated and should not be used in newly-written code. Use <a href="glib-The-Main-Event-Loop.html#g-main-context-pending"><code class="function">g_main_context_pending()</code></a> instead.</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -