~ubuntu-branches/debian/sid/glib2.0/sid

« back to all changes in this revision

Viewing changes to docs/reference/glib/html/glib-The-Main-Event-Loop.html

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 06:25:57 UTC
  • mfrom: (1.27.14) (3.1.181 experimental)
  • Revision ID: package-import@ubuntu.com-20130508062557-i7gbku66mls70gi2
Tags: 2.36.1-2
Merge experimental branch, upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
<link rel="up" href="glib-core.html" title="GLib Core Application Support">
9
9
<link rel="prev" href="glib-core.html" title="GLib Core Application Support">
10
10
<link rel="next" href="glib-Threads.html" title="Threads">
11
 
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
 
11
<meta name="generator" content="GTK-Doc V1.18.1 (XML mode)">
12
12
<link rel="stylesheet" href="style.css" type="text/css">
13
13
</head>
14
14
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
213
213
<span class="returnvalue">void</span>                <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>      (<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>,
214
214
                                                         <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>,
215
215
                                                         <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>);
 
216
<span class="returnvalue">void</span>                <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>             (<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>,
 
217
                                                         <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>);
 
218
<a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="returnvalue">gint64</span></a>              <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>             (<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>);
 
219
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            <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>                (<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>,
 
220
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> fd</code></em>,
 
221
                                                         <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>);
 
222
<span class="returnvalue">void</span>                <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>             (<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>,
 
223
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> tag</code></em>);
 
224
<span class="returnvalue">void</span>                <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>             (<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>,
 
225
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> tag</code></em>,
 
226
                                                         <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>);
 
227
<a class="link" href="glib-IO-Channels.html#GIOCondition" title="enum GIOCondition"><span class="returnvalue">GIOCondition</span></a>        <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>              (<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>,
 
228
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> tag</code></em>);
216
229
<span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-add-poll" title="g_source_add_poll ()">g_source_add_poll</a>                   (<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>,
217
230
                                                         <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>);
218
231
<span class="returnvalue">void</span>                <a class="link" href="glib-The-Main-Event-Loop.html#g-source-remove-poll" title="g_source_remove_poll ()">g_source_remove_poll</a>                (<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>,
277
290
<p>
278
291
</p>
279
292
<div class="refsect2">
280
 
<a name="id606541"></a><h3>Creating new source types</h3>
 
293
<a name="id-1.4.2.4.9.1"></a><h3>Creating new source types</h3>
281
294
<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
282
295
is that new types of event source can be created and used in
283
296
addition to the builtin type of event source. A new event source
300
313
</p>
301
314
<hr>
302
315
<div class="refsect2">
303
 
<a name="id606610"></a><h3>Customizing the main loop iteration</h3>
 
316
<a name="id-1.4.2.4.9.2"></a><h3>Customizing the main loop iteration</h3>
304
317
<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
305
318
<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
306
319
of exactly how the details of the main loop work is desired, for
832
845
checking to see if any event sources are ready to be processed,
833
846
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
834
847
for a source to become ready, then dispatching the highest priority
835
 
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> 
836
 
sources are not waited to become ready, only those highest priority 
837
 
events sources will be dispatched (if any), that are ready at this 
 
848
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>
 
849
sources are not waited to become ready, only those highest priority
 
850
events sources will be dispatched (if any), that are ready at this
838
851
given moment without further waiting.
839
852
</p>
840
853
<p>
841
 
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 
842
 
<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 the wait may 
 
854
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
 
855
<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
843
856
be interrupted for other reasons than an event source becoming ready.
844
857
</p>
845
858
<div class="variablelist"><table border="0" class="variablelist">
1266
1279
<tr>
1267
1280
<td><p><span class="term"><em class="parameter"><code>fds</code></em> :</span></p></td>
1268
1281
<td>location to
1269
 
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. <span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym> caller-allocates][<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=n_fds]</span>
 
1282
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. <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>
1270
1283
</td>
1271
1284
</tr>
1272
1285
<tr>
1450
1463
<p>
1451
1464
Adds a file descriptor to the set of file descriptors polled for
1452
1465
this context. This will very seldom be used directly. Instead
1453
 
a typical event source will use <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> instead.
 
1466
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.
1454
1467
</p>
1455
1468
<div class="variablelist"><table border="0" class="variablelist">
1456
1469
<colgroup>
1958
1971
<p>
1959
1972
Beware that libraries that predate this function may not correctly
1960
1973
handle being used from a thread with a thread-default context. Eg,
1961
 
see <a href="http://library.gnome.org/devel/gio/unstable/GFile.html#g-file-supports-thread-contexts"><code class="function">g_file_supports_thread_contexts()</code></a>.
 
1974
see <code class="function">g_file_supports_thread_contexts()</code>.
1962
1975
</p>
1963
1976
<div class="variablelist"><table border="0" class="variablelist">
1964
1977
<colgroup>
2500
2513
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> status</code></em>,
2501
2514
                                                         <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>
2502
2515
<p>
2503
 
The type of functions to be called when a child exists.
 
2516
Prototype of a <span class="type">GChildWatchSource</span> callback, called when a child
 
2517
process has exited.  To interpret <em class="parameter"><code>status</code></em>, see the documentation
 
2518
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>.
2504
2519
</p>
2505
2520
<div class="variablelist"><table border="0" class="variablelist">
2506
2521
<colgroup>
2514
2529
</tr>
2515
2530
<tr>
2516
2531
<td><p><span class="term"><em class="parameter"><code>status</code></em> :</span></p></td>
2517
 
<td>Status information about the child process,
2518
 
see waitpid(2) for more information about this field</td>
 
2532
<td>Status information about the child process, encoded
 
2533
in a platform-specific manner</td>
2519
2534
</tr>
2520
2535
<tr>
2521
2536
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
2549
2564
<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.
2550
2565
</p>
2551
2566
<p>
2552
 
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 
2553
 
compatible with calling <code class="literal">waitpid(-1)</code> in 
2554
 
the application. Calling <code class="function">waitpid()</code> for individual pids will
2555
 
still work fine.
 
2567
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
 
2568
compatible with calling <code class="literal">waitpid</code> with a
 
2569
nonpositive first argument in the application. Calling <code class="function">waitpid()</code>
 
2570
for individual pids will still work fine.
2556
2571
</p>
2557
2572
<div class="variablelist"><table border="0" class="variablelist">
2558
2573
<colgroup>
2649
2664
the spawn function for the child watching to work.
2650
2665
</p>
2651
2666
<p>
2652
 
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
2653
 
(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
2654
 
source is still active. Typically, you will want to call
2655
 
<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.
 
2667
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>
 
2668
in the callback to determine whether or not the child exited
 
2669
successfully.
 
2670
</p>
 
2671
<p>
 
2672
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
 
2673
(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
 
2674
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>
 
2675
in the callback function for the source.
2656
2676
</p>
2657
2677
<p>
2658
2678
GLib supports only a single callback per process id.
2826
2846
<a name="GSourceDummyMarshal"></a><h3>GSourceDummyMarshal ()</h3>
2827
2847
<pre class="programlisting"><span class="returnvalue">void</span>                (*GSourceDummyMarshal)              (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
2828
2848
<p>
2829
 
This is just a placeholder for <a href="http://library.gnome.org/devel/gobject/unstable/gobject-Closures.html#GClosureMarshal"><span class="type">GClosureMarshal</span></a>,
 
2849
This is just a placeholder for <span class="type">GClosureMarshal</span>,
2830
2850
which cannot be used here for dependency reasons.
2831
2851
</p>
2832
2852
</div>
2843
2863
  void     (*finalize) (GSource    *source); /* Can be NULL */
2844
2864
};
2845
2865
</pre>
2846
 
<p>
2847
 
The <span class="structname">GSourceFuncs</span> struct contains a table of
2848
 
functions used to handle event sources in a generic manner.
2849
 
</p>
2850
 
<p>
2851
 
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>
2852
 
to indicate that the source is always ready to be processed. The prepare
2853
 
function also returns a timeout value of 0 to ensure that the <code class="function">poll()</code> call
2854
 
doesn't block (since that would be time wasted which could have been spent
2855
 
running the idle function).
2856
 
</p>
2857
 
<p>
2858
 
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>
2859
 
if the timeout interval has expired. The prepare function also returns
2860
 
a timeout value to ensure that the <code class="function">poll()</code> call doesn't block too long
2861
 
and miss the next timeout.
2862
 
</p>
2863
 
<p>
2864
 
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>,
2865
 
since it must wait until <code class="function">poll()</code> has been called before it knows whether
2866
 
any events need to be processed. It sets the returned timeout to -1 to
2867
 
indicate that it doesn't mind how long the <code class="function">poll()</code> call blocks. In the
2868
 
check function, it tests the results of the <code class="function">poll()</code> call to see if the
2869
 
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.
2870
 
</p>
2871
2866
<div class="variablelist"><table border="0" class="variablelist">
2872
2867
<colgroup>
2873
2868
<col align="left" valign="top">
2882
2877
a <em class="parameter"><code>timeout_</code></em> value which should be the maximum timeout (in milliseconds)
2883
2878
which should be passed to the <code class="function">poll()</code> call. The actual timeout used will
2884
2879
be -1 if all sources returned -1, or it will be the minimum of all the
2885
 
<em class="parameter"><code>timeout_</code></em> values returned which were &gt;= 0.</td>
 
2880
<em class="parameter"><code>timeout_</code></em> values returned which were &gt;= 0.  Since 2.36 this may
 
2881
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</td>
2886
2882
</tr>
2887
2883
<tr>
2888
2884
<td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.check"></a>check</code></em> ()</span></p></td>
2889
 
<td>Called after all the file descriptors are polled. The source
2890
 
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
2891
 
time may have passed since the previous prepare function was called,
2892
 
so the source should be checked again here.</td>
 
2885
<td></td>
2893
2886
</tr>
2894
2887
<tr>
2895
2888
<td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.dispatch"></a>dispatch</code></em> ()</span></p></td>
2896
 
<td>Called to dispatch the event source, after it has returned
2897
 
<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>
2898
 
function is passed in a callback function and data. The callback
2899
 
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
2900
 
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
2901
 
callback function with <em class="parameter"><code>user_data</code></em> and whatever additional parameters
2902
 
are needed for this type of event source.</td>
 
2889
<td></td>
2903
2890
</tr>
2904
2891
<tr>
2905
2892
<td><p><span class="term"><em class="structfield"><code><a name="GSourceFuncs.finalize"></a>finalize</code></em> ()</span></p></td>
2906
 
<td>Called when the source is finalized.</td>
 
2893
<td></td>
2907
2894
</tr>
2908
2895
</tbody>
2909
2896
</table></div>
3187
3174
<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">-&gt;</span><span class="normal">idle_id</span><span class="symbol">)</span>
3188
3175
<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">-&gt;</span><span class="normal">idle_id</span><span class="symbol">);</span>
3189
3176
<span class="normal">   </span>
3190
 
<span class="normal">  </span><span class="function"><a href="http://library.gnome.org/devel/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">)-&gt;</span><span class="function">finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span>
 
3177
<span class="normal">  </span><span class="function">G_OBJECT_CLASS</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">parent_class</span><span class="symbol">)-&gt;</span><span class="function">finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span>
3191
3178
<span class="cbracket">}</span></pre></td>
3192
3179
      </tr>
3193
3180
    </tbody>
3504
3491
<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>
3505
3492
<p>
3506
3493
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.
3507
 
Calling this function on a destroyed source is an error.
 
3494
</p>
 
3495
<p>
 
3496
You can call this on a source that has been destroyed, provided
 
3497
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
 
3498
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
 
3499
always call this function on the source returned from
 
3500
<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
 
3501
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.
3508
3502
</p>
3509
3503
<div class="variablelist"><table border="0" class="variablelist">
3510
3504
<colgroup>
3638
3632
</div>
3639
3633
<hr>
3640
3634
<div class="refsect2">
 
3635
<a name="g-source-set-ready-time"></a><h3>g_source_set_ready_time ()</h3>
 
3636
<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>,
 
3637
                                                         <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>
 
3638
<p>
 
3639
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
 
3640
reached (or passed).  If the monotonic time is in the past (as it
 
3641
always will be if <em class="parameter"><code>ready_time</code></em> is 0) then the source will be
 
3642
dispatched immediately.
 
3643
</p>
 
3644
<p>
 
3645
If <em class="parameter"><code>ready_time</code></em> is -1 then the source is never woken up on the basis
 
3646
of the passage of time.
 
3647
</p>
 
3648
<p>
 
3649
Dispatching the source does not reset the ready time.  You should do
 
3650
so yourself, from the source dispatch function.
 
3651
</p>
 
3652
<p>
 
3653
Note that if you have a pair of sources where the ready time of one
 
3654
suggests that it will be delivered first but the priority for the
 
3655
other suggests that it would be delivered first, and the ready time
 
3656
for both sources is reached during the same main context iteration
 
3657
then the order of dispatch is undefined.
 
3658
</p>
 
3659
<div class="variablelist"><table border="0" class="variablelist">
 
3660
<colgroup>
 
3661
<col align="left" valign="top">
 
3662
<col>
 
3663
</colgroup>
 
3664
<tbody>
 
3665
<tr>
 
3666
<td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
 
3667
<td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
 
3668
</td>
 
3669
</tr>
 
3670
<tr>
 
3671
<td><p><span class="term"><em class="parameter"><code>ready_time</code></em> :</span></p></td>
 
3672
<td>the monotonic time at which the source will be ready,
 
3673
0 for "immediately", -1 for "never"</td>
 
3674
</tr>
 
3675
</tbody>
 
3676
</table></div>
 
3677
<p class="since">Since 2.36</p>
 
3678
</div>
 
3679
<hr>
 
3680
<div class="refsect2">
 
3681
<a name="g-source-get-ready-time"></a><h3>g_source_get_ready_time ()</h3>
 
3682
<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>
 
3683
<p>
 
3684
Gets the "ready time" of <em class="parameter"><code>source</code></em>, as set by
 
3685
<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>.
 
3686
</p>
 
3687
<p>
 
3688
Any time before the current monotonic time (including 0) is an
 
3689
indication that the source will fire immediately.
 
3690
</p>
 
3691
<div class="variablelist"><table border="0" class="variablelist">
 
3692
<colgroup>
 
3693
<col align="left" valign="top">
 
3694
<col>
 
3695
</colgroup>
 
3696
<tbody>
 
3697
<tr>
 
3698
<td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
 
3699
<td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
 
3700
</td>
 
3701
</tr>
 
3702
<tr>
 
3703
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
 
3704
<td>the monotonic ready time, -1 for "never"</td>
 
3705
</tr>
 
3706
</tbody>
 
3707
</table></div>
 
3708
</div>
 
3709
<hr>
 
3710
<div class="refsect2">
 
3711
<a name="g-source-add-unix-fd"></a><h3>g_source_add_unix_fd ()</h3>
 
3712
<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>,
 
3713
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> fd</code></em>,
 
3714
                                                         <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>
 
3715
<p>
 
3716
Monitors <em class="parameter"><code>fd</code></em> for the IO events in <em class="parameter"><code>events</code></em>.
 
3717
</p>
 
3718
<p>
 
3719
The tag returned by this function can be used to remove or modify the
 
3720
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
 
3721
<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>.
 
3722
</p>
 
3723
<p>
 
3724
It is not necessary to remove the fd before destroying the source; it
 
3725
will be cleaned up automatically.
 
3726
</p>
 
3727
<p>
 
3728
As the name suggests, this function is not available on Windows.
 
3729
</p>
 
3730
<div class="variablelist"><table border="0" class="variablelist">
 
3731
<colgroup>
 
3732
<col align="left" valign="top">
 
3733
<col>
 
3734
</colgroup>
 
3735
<tbody>
 
3736
<tr>
 
3737
<td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
 
3738
<td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
 
3739
</td>
 
3740
</tr>
 
3741
<tr>
 
3742
<td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td>
 
3743
<td>the fd to monitor</td>
 
3744
</tr>
 
3745
<tr>
 
3746
<td><p><span class="term"><em class="parameter"><code>events</code></em> :</span></p></td>
 
3747
<td>an event mask</td>
 
3748
</tr>
 
3749
<tr>
 
3750
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
 
3751
<td>an opaque tag</td>
 
3752
</tr>
 
3753
</tbody>
 
3754
</table></div>
 
3755
<p class="since">Since 2.36</p>
 
3756
</div>
 
3757
<hr>
 
3758
<div class="refsect2">
 
3759
<a name="g-source-remove-unix-fd"></a><h3>g_source_remove_unix_fd ()</h3>
 
3760
<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>,
 
3761
                                                         <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>
 
3762
<p>
 
3763
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>.
 
3764
</p>
 
3765
<p>
 
3766
You only need to call this if you want to remove an fd from being
 
3767
watched while keeping the same source around.  In the normal case you
 
3768
will just want to destroy the source.
 
3769
</p>
 
3770
<p>
 
3771
As the name suggests, this function is not available on Windows.
 
3772
</p>
 
3773
<div class="variablelist"><table border="0" class="variablelist">
 
3774
<colgroup>
 
3775
<col align="left" valign="top">
 
3776
<col>
 
3777
</colgroup>
 
3778
<tbody>
 
3779
<tr>
 
3780
<td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
 
3781
<td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
 
3782
</td>
 
3783
</tr>
 
3784
<tr>
 
3785
<td><p><span class="term"><em class="parameter"><code>tag</code></em> :</span></p></td>
 
3786
<td>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>
 
3787
</td>
 
3788
</tr>
 
3789
</tbody>
 
3790
</table></div>
 
3791
<p class="since">Since 2.36</p>
 
3792
</div>
 
3793
<hr>
 
3794
<div class="refsect2">
 
3795
<a name="g-source-modify-unix-fd"></a><h3>g_source_modify_unix_fd ()</h3>
 
3796
<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>,
 
3797
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> tag</code></em>,
 
3798
                                                         <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>
 
3799
<p>
 
3800
Updates the event mask to watch for the fd identified by <em class="parameter"><code>tag</code></em>.
 
3801
</p>
 
3802
<p>
 
3803
<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>.
 
3804
</p>
 
3805
<p>
 
3806
If you want to remove a fd, don't set its event mask to zero.
 
3807
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>.
 
3808
</p>
 
3809
<p>
 
3810
As the name suggests, this function is not available on Windows.
 
3811
</p>
 
3812
<div class="variablelist"><table border="0" class="variablelist">
 
3813
<colgroup>
 
3814
<col align="left" valign="top">
 
3815
<col>
 
3816
</colgroup>
 
3817
<tbody>
 
3818
<tr>
 
3819
<td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
 
3820
<td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
 
3821
</td>
 
3822
</tr>
 
3823
<tr>
 
3824
<td><p><span class="term"><em class="parameter"><code>tag</code></em> :</span></p></td>
 
3825
<td>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>
 
3826
</td>
 
3827
</tr>
 
3828
<tr>
 
3829
<td><p><span class="term"><em class="parameter"><code>new_events</code></em> :</span></p></td>
 
3830
<td>the new event mask to watch</td>
 
3831
</tr>
 
3832
</tbody>
 
3833
</table></div>
 
3834
<p class="since">Since 2.36</p>
 
3835
</div>
 
3836
<hr>
 
3837
<div class="refsect2">
 
3838
<a name="g-source-query-unix-fd"></a><h3>g_source_query_unix_fd ()</h3>
 
3839
<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>,
 
3840
                                                         <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>
 
3841
<p>
 
3842
Queries the events reported for the fd corresponding to <em class="parameter"><code>tag</code></em> on
 
3843
<em class="parameter"><code>source</code></em> during the last poll.
 
3844
</p>
 
3845
<p>
 
3846
The return value of this function is only defined when the function
 
3847
is called from the check or dispatch functions for <em class="parameter"><code>source</code></em>.
 
3848
</p>
 
3849
<p>
 
3850
As the name suggests, this function is not available on Windows.
 
3851
</p>
 
3852
<div class="variablelist"><table border="0" class="variablelist">
 
3853
<colgroup>
 
3854
<col align="left" valign="top">
 
3855
<col>
 
3856
</colgroup>
 
3857
<tbody>
 
3858
<tr>
 
3859
<td><p><span class="term"><em class="parameter"><code>source</code></em> :</span></p></td>
 
3860
<td>a <a class="link" href="glib-The-Main-Event-Loop.html#GSource" title="struct GSource"><span class="type">GSource</span></a>
 
3861
</td>
 
3862
</tr>
 
3863
<tr>
 
3864
<td><p><span class="term"><em class="parameter"><code>tag</code></em> :</span></p></td>
 
3865
<td>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>
 
3866
</td>
 
3867
</tr>
 
3868
<tr>
 
3869
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
 
3870
<td>the conditions reported on the fd</td>
 
3871
</tr>
 
3872
</tbody>
 
3873
</table></div>
 
3874
<p class="since">Since 2.36</p>
 
3875
</div>
 
3876
<hr>
 
3877
<div class="refsect2">
3641
3878
<a name="g-source-add-poll"></a><h3>g_source_add_poll ()</h3>
3642
3879
<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>,
3643
3880
                                                         <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>
3648
3885
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
3649
3886
to be processed.
3650
3887
</p>
 
3888
<p>
 
3889
Using this API forces the linear scanning of event sources on each
 
3890
main loop iteration.  Newly-written event sources should try to use
 
3891
<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.
 
3892
</p>
3651
3893
<div class="variablelist"><table border="0" class="variablelist">
3652
3894
<colgroup>
3653
3895
<col align="left" valign="top">
3710
3952
</p>
3711
3953
<p>
3712
3954
If you don't need <em class="parameter"><code>child_source</code></em> to do anything on its own when it
3713
 
triggers, you can call <a href="http://library.gnome.org/devel/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
 
3955
triggers, you can call <code class="function">g_source_set_dummy_callback()</code> on it to set a
3714
3956
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).
3715
3957
</p>
3716
3958
<p>
3927
4169
</div>
3928
4170
<div class="footer">
3929
4171
<hr>
3930
 
          Generated by GTK-Doc V1.18</div>
 
4172
          Generated by GTK-Doc V1.18.1</div>
3931
4173
</body>
3932
4174
</html>
 
 
b'\\ No newline at end of file'