📄 main.sgml
字号:
</entry></row><row><entry align="right"><parameter>fds</parameter> :</entry><entry> array of <link linkend="GPollFD">GPollFD</link>'s that was passed to the last call to <link linkend="g-main-context-query">g_main_context_query</link>()</entry></row><row><entry align="right"><parameter>n_fds</parameter> :</entry><entry> return value of <link linkend="g-main-context-query">g_main_context_query</link>()</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> <literal>TRUE</literal> if some sources are ready to be dispatched.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-main-context-dispatch">g_main_context_dispatch ()</title><programlisting>void g_main_context_dispatch (<link linkend="GMainContext">GMainContext</link> *context);</programlisting><para>Dispatches all pending sources.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>context</parameter> :</entry><entry> a <link linkend="GMainContext">GMainContext</link></entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-main-context-set-poll-func">g_main_context_set_poll_func ()</title><programlisting>void g_main_context_set_poll_func (<link linkend="GMainContext">GMainContext</link> *context, <link linkend="GPollFunc">GPollFunc</link> func);</programlisting><para>Sets the function to use to handle polling of file descriptors. Itwill be used instead of the <function><link linkend="poll">poll</link>()</function> system call (or GLib's replacement function, which is used where <function><link linkend="poll">poll</link>()</function> isn't available).</para><para>This function could possibly be used to integrate the GLib eventloop with an external event loop.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>context</parameter> :</entry><entry> a <link linkend="GMainContext">GMainContext</link></entry></row><row><entry align="right"><parameter>func</parameter> :</entry><entry> the function to call to poll all file descriptors</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-main-context-get-poll-func">g_main_context_get_poll_func ()</title><programlisting><link linkend="GPollFunc">GPollFunc</link> g_main_context_get_poll_func (<link linkend="GMainContext">GMainContext</link> *context);</programlisting><para>Gets the poll function set by <link linkend="g-main-context-set-poll-func">g_main_context_set_poll_func</link>().</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>context</parameter> :</entry><entry> a <link linkend="GMainContext">GMainContext</link></entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> the poll function</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GPollFunc">GPollFunc ()</title><programlisting><link linkend="gint">gint</link> (*GPollFunc) (<link linkend="GPollFD">GPollFD</link> *ufds, <link linkend="guint">guint</link> nfsd, <link linkend="gint">gint</link> timeout);</programlisting><para>Specifies the type of function passed to <link linkend="g-main-set-poll-func">g_main_set_poll_func</link>().The semantics of the function should match those of the<function><link linkend="poll">poll</link>()</function> system call.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>ufds</parameter> :</entry><entry>an array of <link linkend="GPollFD">GPollFD</link> elements.</entry></row><row><entry align="right"><parameter>nfsd</parameter> :</entry><entry>the number of elements in <parameter>ufds</parameter>.</entry></row><row><entry align="right"><parameter>timeout</parameter> :</entry><entry>the maximum time to wait for an event of the file descriptors. A negative value indicates an infinite timeout.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the number of <link linkend="GPollFD">GPollFD</link> elements which have events or errors reported,or -1 if an error occurred.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-main-context-add-poll">g_main_context_add_poll ()</title><programlisting>void g_main_context_add_poll (<link linkend="GMainContext">GMainContext</link> *context, <link linkend="GPollFD">GPollFD</link> *fd, <link linkend="gint">gint</link> priority);</programlisting><para>Adds a file descriptor to the set of file descriptors polled forthis context. This will very seldomly be used directly. Insteada typical event source will use <link linkend="g-source-add-poll">g_source_add_poll</link>() instead.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>context</parameter> :</entry><entry> a <link linkend="GMainContext">GMainContext</link> (or <literal>NULL</literal> for the default context)</entry></row><row><entry align="right"><parameter>fd</parameter> :</entry><entry> a <link linkend="GPollFD">GPollFD</link> structure holding information about a file descriptor to watch.</entry></row><row><entry align="right"><parameter>priority</parameter> :</entry><entry> the priority for this file descriptor which should be the same as the priority used for <link linkend="g-source-attach">g_source_attach</link>() to ensure that the file descriptor is polled whenever the results may be needed.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-main-context-remove-poll">g_main_context_remove_poll ()</title><programlisting>void g_main_context_remove_poll (<link linkend="GMainContext">GMainContext</link> *context, <link linkend="GPollFD">GPollFD</link> *fd);</programlisting><para>Removes file descriptor from the set of file descriptors to bepolled for a particular context.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>context</parameter> :</entry><entry>a <link linkend="GMainContext">GMainContext</link> </entry></row><row><entry align="right"><parameter>fd</parameter> :</entry><entry> a <link linkend="GPollFD">GPollFD</link> descriptor previously added with <link linkend="g-main-context-add-poll">g_main_context_add_poll</link>()</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-main-set-poll-func">g_main_set_poll_func()</title><programlisting>#define g_main_set_poll_func(func)</programlisting><warning><para><literal>g_main_set_poll_func</literal> is deprecated and should not be used in newly-written code.</para></warning><para>Sets the function to use for the handle polling of file descriptorsfor the default main context. This is a compatability macro, see<link linkend="g-main-context-set-poll-func">g_main_context_set_poll_func</link>() for full details.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>func</parameter> :</entry><entry>the function to call to poll all file descriptors.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-timeout-source-new">g_timeout_source_new ()</title><programlisting><link linkend="GSource">GSource</link>* g_timeout_source_new (<link linkend="guint">guint</link> interval);</programlisting><para>Creates a new timeout source.</para><para>The source will not initially be associated with any <link linkend="GMainContext">GMainContext</link>and must be added to one with <link linkend="g-source-attach">g_source_attach</link>() before it will beexecuted.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>interval</parameter> :</entry><entry> the timeout interval in milliseconds.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> the newly-created timeout source</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-timeout-add">g_timeout_add ()</title><programlisting><link linkend="guint">guint</link> g_timeout_add (<link linkend="guint">guint</link> interval, <link linkend="GSourceFunc">GSourceFunc</link> function, <link linkend="gpointer">gpointer</link> data);</programlisting><para>Sets a function to be called at regular intervals, with the defaultpriority, <link linkend="G-PRIORITY-DEFAULT-CAPS">G_PRIORITY_DEFAULT</link>. The function is called repeatedlyuntil it returns <literal>FALSE</literal>, at which point the timeout is automaticallydestroyed and the function will not be called again. The <parameter>notify</parameter>function is called when the timeout is destroyed. The first callto the function will be at the end of the first <parameter>interval</parameter>.</para><para>Note that timeout functions may be delayed, due to the processing of otherevent sources. Thus they should not be relied on for precise timing.After each call to the timeout function, the time of the nexttimeout is recalculated based on the current time and the given interval(it does not try to 'catch up' time lost in delays).</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>interval</parameter> :</entry><entry> the time between calls to the function, in milliseconds (1/1000ths of a second)</entry></row><row><entry align="right"><parameter>function</parameter> :</entry><entry> function to call</entry></row><row><entry align="right"><parameter>data</parameter> :</entry><entry> data to pass to <parameter>function</parameter></entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> the id of event source.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-timeout-add-full">g_timeout_add_full ()</title><programlisting><link linkend="guint"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -