📄 main.sgml
字号:
</para>@context: @func: <!-- ##### FUNCTION g_main_context_get_poll_func ##### --><para></para>@context: @Returns: <!-- ##### USER_FUNCTION GPollFunc ##### --><para>Specifies the type of function passed to g_main_set_poll_func().The semantics of the function should match those of the<function>poll()</function> system call.</para>@ufds: an array of #GPollFD elements.@nfsd: the number of elements in @ufds.@timeout: the maximum time to wait for an event of the file descriptors. A negative value indicates an infinite timeout.@Returns: the number of #GPollFD elements which have events or errors reported,or -1 if an error occurred.<!-- ##### FUNCTION g_main_context_add_poll ##### --><para></para>@context: @fd: @priority: <!-- ##### FUNCTION g_main_context_remove_poll ##### --><para></para>@context: @fd: <!-- ##### MACRO g_main_set_poll_func ##### --><para>Sets the function to use for the handle polling of file descriptorsfor the default main context. This is a compatability macro, seeg_main_context_set_poll_func() for full details.</para>@func: the function to call to poll all file descriptors.<!-- ##### FUNCTION g_timeout_source_new ##### --><para></para>@interval: @Returns: <!-- ##### FUNCTION g_timeout_add ##### --><para></para>@interval: @function: @data: @Returns: <!-- ##### FUNCTION g_timeout_add_full ##### --><para></para>@priority: @interval: @function: @data: @notify: @Returns: <!-- ##### FUNCTION g_idle_source_new ##### --><para></para>@Returns: <!-- ##### FUNCTION g_idle_add ##### --><para></para>@function: @data: @Returns: <!-- ##### FUNCTION g_idle_add_full ##### --><para></para>@priority: @function: @data: @notify: @Returns: <!-- ##### FUNCTION g_idle_remove_by_data ##### --><para></para>@data: @Returns: <!-- ##### STRUCT GPollFD ##### --><para><informaltable pgwide=1 frame="none" role="struct"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry>#gint fd;</entry><entry>the file descriptor to poll (or a <type>HANDLE</type> on Win32 platforms).</entry></row><row><entry>#gushort events;</entry><entry>a bitwise combination of flags from #GIOCondition, specifying whichevents should be polled for. Typically for reading from a file descriptoryou would use %G_IO_IN | %G_IO_HUP | %G_IO_ERR, and for writing you would use%G_IO_OUT | %G_IO_ERR.</entry></row><row><entry>#gushort revents;</entry><entry>a bitwise combination of flags from #GIOCondition, returned from the<function>poll()</function> function to indicate which events occurred.</entry></row></tbody></tgroup></informaltable></para>@fd: @events: @revents: <!-- ##### STRUCT GSource ##### --><para>The <structname>GSource</structname> struct is an opaque data type representingan event source.</para><!-- ##### STRUCT GSourceFuncs ##### --><para>The #GSourceFuncs struct contains a table of functions used to handleevent sources in a generic manner.<informaltable pgwide=1 frame="none" role="struct"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry>prepare</entry><entry>Called before all the file descriptors are polled.If the source can determine that it is ready here (without waiting for theresults of the <function>poll()</function> call) it should return %TRUE.It can also return a @timeout value which should be the maximum timeout(in milliseconds) which should be passed to the <function>poll()</function> call.The actual timeout used will be -1 if all sources returned -1, or it willbe the minimum of all the @timeout values returned which were >= 0.</entry></row><row><entry>check</entry><entry>Called after all the file descriptors are polled.The source should return %TRUE if it is ready to be dispatched.Note that some time may have passed since the previous prepare function wascalled, so the source should be checked again here.</entry></row><row><entry>dispatch</entry><entry>Called to dispatch the event source, after it has returned %TRUE ineither its @prepare or its @check function. The @dispatch function ispassed in a callback function and data. The callback function may be%NULL if the source was never connected using g_source_connect(). The@dispatch function should call the callback function with data andwhatever additional parameters are needed for this type of event source.</entry></row><row><entry>finalize</entry><entry>Called when the source is finalized.</entry></row></tbody></tgroup></informaltable></para><para>For idle sources, the prepare and check functions always return %TRUE toindicate that the source is always ready to be processed.The prepare function also returns a timeout value of 0 to ensure that the<function>poll()</function> call doesn't block (since that would be time wasted which could have been spent running the idle function).</para><para>For timeout sources, the prepare and check functions both return %TRUE if thetimeout interval has expired. The prepare function also returns a timeout value to ensure that the <function>poll()</function> call doesn't block too long and miss the next timeout.</para><para>For file descriptor sources, the prepare function typically returns %FALSE,since it must wait until <function>poll()</function> 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 <function>poll()</function> call blocks.In the check function, it tests the results of the <function>poll()</function>call to see if the required condition has been met, and returns %TRUE if so.</para>@prepare: @check: @dispatch: @finalize: @closure_callback: @closure_marshal: <!-- ##### STRUCT GSourceCallbackFuncs ##### --><para>The <structname>GSourceCallbackFuncs</structname> struct containsfunctions for managing callback objects. </para>@ref: Called when a reference is added to the callback object.@unref: Called when a reference to the callback object is dropped.@get: Called to extract the callback function and data from the callback object.<!-- ##### USER_FUNCTION GSourceDummyMarshal ##### --><para></para><!-- ##### FUNCTION g_source_new ##### --><para></para>@source_funcs: @struct_size: @Returns: <!-- ##### FUNCTION g_source_ref ##### --><para></para>@source: @Returns: <!-- ##### FUNCTION g_source_unref ##### --><para></para>@source: <!-- ##### FUNCTION g_source_attach ##### --><para></para>@source: @context: @Returns: <!-- ##### FUNCTION g_source_destroy ##### --><para></para>@source: <!-- ##### FUNCTION g_source_set_priority ##### --><para></para>@source: @priority: <!-- ##### FUNCTION g_source_get_priority ##### --><para></para>@source: @Returns: <!-- ##### FUNCTION g_source_set_can_recurse ##### --><para></para>@source: @can_recurse: <!-- ##### FUNCTION g_source_get_can_recurse ##### --><para></para>@source: @Returns: <!-- ##### FUNCTION g_source_get_id ##### --><para></para>@source: @Returns: <!-- ##### FUNCTION g_source_get_context ##### --><para></para>@source: @Returns: <!-- ##### FUNCTION g_source_set_callback ##### --><para></para>@source: @func: @data: @notify: <!-- ##### USER_FUNCTION GSourceFunc ##### --><para>Specifies the type of function passed to g_timeout_add(), g_timeout_add_full(),g_idle_add(), and g_idle_add_full().</para>@data: data passed to the function, set when the source was created with oneof the above functions.@Returns: it should return %FALSE if the source should be removed.<!-- ##### FUNCTION g_source_set_callback_indirect ##### --><para></para>@source: @callback_data: @callback_funcs: <!-- ##### FUNCTION g_source_add_poll ##### --><para></para>@source: @fd: <!-- ##### FUNCTION g_source_remove_poll ##### --><para></para>@source: @fd: <!-- ##### FUNCTION g_source_get_current_time ##### --><para></para>@source: @timeval: <!-- ##### FUNCTION g_source_remove ##### --><para></para>@tag: @Returns: <!-- ##### FUNCTION g_source_remove_by_funcs_user_data ##### --><para></para>@funcs: @user_data: @Returns: <!-- ##### FUNCTION g_source_remove_by_user_data ##### --><para></para>@user_data: @Returns: <!--Local variables:mode: sgmlsgml-parent-document: ("../glib-docs.sgml" "book" "refsect2" "")End:-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -