123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title><GSource>: </title>
- <meta name="generator" content="DocBook XSL Stylesheets V1.79.2">
- <link rel="home" href="index.html" title="">
- <link rel="up" href="ch01.html" title="GLib">
- <link rel="prev" href="re57.html" title="<%GLibSliceConfig>">
- <link rel="next" href="re59.html" title="<%GLibSpawnError>">
- <meta name="generator" content="GTK-Doc V1.33.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"></td>
- <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
- <td><img src="up-insensitive.png" width="16" height="16" border="0"></td>
- <td><a accesskey="p" href="re57.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
- <td><a accesskey="n" href="re59.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
- </tr></table>
- <div class="refentry">
- <a name="id-1.1.59"></a><div class="titlepage"></div>
- <div class="refnamediv">
- <h2><GSource></h2>
- <p><GSource></p>
- </div>
- <div class="refsect1">
- <a name="id-1.1.59.2"></a><h2>Description</h2>
- <p>The <code class="code">GSource</code> struct is an opaque data type
- representing an event source.</p>
- </div>
- <div class="refsect1">
- <a name="id-1.1.59.3"></a><h2>Functions</h2>
- <div class="refsect2">
- <a name="id-1.1.59.3.2"></a><h3>add-child-source</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:add-child-source self child-source))
- </pre></div>
- <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 <span class="type">GMainContext</span>, <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 <code class="function">g_source_set_dummy_callback()</code> on it to set a
- callback that does nothing (except return <code class="constant">TRUE</code> 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 <span class="type">GSource</span>.
- Do not call this API on a <span class="type">GSource</span> that you did not create.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.2.7"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>child_source</p></td>
- <td class="parameter_description">
- <p>a second <span class="type">GSource</span> that <em class="parameter"><code>source</code></em> should "poll"</p>
- <p>Passed as <code class="code">child-source</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.3"></a><h3>add-poll</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:add-poll self fd))
- </pre></div>
- <p>Adds a file descriptor to the set of file descriptors polled for
- this source. This is usually combined with <code class="function">g_source_new()</code> 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 <span class="type">GPollFD</span> struct and return <code class="constant">TRUE</code> if events need
- to be processed.
- </p>
- <p>This API is only intended to be used by implementations of <span class="type">GSource</span>.
- Do not call this API on a <span class="type">GSource</span> 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
- <code class="function">g_source_add_unix_fd()</code> instead of this API.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.3.6"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>fd</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GPollFD</span> structure holding information about a file
- descriptor to watch.</p>
- <p>Passed as <code class="code">fd</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.4"></a><h3>add-unix-fd</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:add-unix-fd self fd events))
- </pre></div>
- <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 <code class="function">g_source_remove_unix_fd()</code> or
- <code class="function">g_source_modify_unix_fd()</code>.
- </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 <span class="type">GSource</span>.
- Do not call this API on a <span class="type">GSource</span> that you did not create.
- </p>
- <p>As the name suggests, this function is not available on Windows.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.4.8"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>fd</p></td>
- <td class="parameter_description">
- <p>the fd to monitor</p>
- <p>Passed as <code class="code">fd</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>events</p></td>
- <td class="parameter_description">
- <p>an event mask</p>
- <p>Passed as <code class="code">events</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.5"></a><h3>attach</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:attach self context))
- </pre></div>
- <p>Adds a <span class="type">GSource</span> to a <em class="parameter"><code>context</code></em> so that it will be executed within
- that context. Remove it by calling <code class="function">g_source_destroy()</code>.
- </p>
- <p>This function is safe to call from any thread, regardless of which thread
- the <em class="parameter"><code>context</code></em> is running in.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.5.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>context</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GMainContext</span> (if <code class="constant">NULL</code>, the default context will be used)</p>
- <p>Passed as <code class="code">context</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.6"></a><h3>destroy</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:destroy self))
- </pre></div>
- <p>Removes a source from its <span class="type">GMainContext</span>, 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>
- <p>This does not unref the #GSource: if you still hold a reference, use
- <code class="function">g_source_unref()</code> to drop it.
- </p>
- <p>This function is safe to call from any thread, regardless of which thread
- the <span class="type">GMainContext</span> is running in.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.6.6"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.7"></a><h3>get-can-recurse?</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:get-can-recurse? self))
- </pre></div>
- <p>Checks whether a source is allowed to be called recursively.
- see <code class="function">g_source_set_can_recurse()</code>.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.7.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.8"></a><h3>get-context</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:get-context self))
- </pre></div>
- <p>Gets the <span class="type">GMainContext</span> with which the source is associated.
- </p>
- <p>You can call this on a source that has been destroyed, provided
- that the <span class="type">GMainContext</span> it was attached to still exists (in which
- case it will return that <span class="type">GMainContext</span>). In particular, you can
- always call this function on the source returned from
- <code class="function">g_main_current_source()</code>. But calling this function on a source
- whose <span class="type">GMainContext</span> has been destroyed is an error.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.8.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.9"></a><h3>get-id</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:get-id self))
- </pre></div>
- <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 <code class="function">g_main_context_find_source_by_id()</code>.
- </p>
- <p>You can only call this function while the source is associated to a
- <span class="type">GMainContext</span> instance; calling this function before <code class="function">g_source_attach()</code>
- or after <code class="function">g_source_destroy()</code> yields undefined behavior. The ID returned
- is unique within the <span class="type">GMainContext</span> instance passed to <code class="function">g_source_attach()</code>.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.9.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.10"></a><h3>get-name</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:get-name self))
- </pre></div>
- <p>Gets a name for the source, used in debugging and profiling. The
- name may be <span class="type">NULL</span> if it has never been set with <code class="function">g_source_set_name()</code>.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.10.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.11"></a><h3>get-priority</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:get-priority self))
- </pre></div>
- <p>Gets the priority of a source.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.11.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.12"></a><h3>get-ready-time</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:get-ready-time self))
- </pre></div>
- <p>Gets the "ready time" of <em class="parameter"><code>source</code></em>, as set by
- <code class="function">g_source_set_ready_time()</code>.
- </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="id-1.1.59.3.12.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.13"></a><h3>get-time</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:get-time self))
- </pre></div>
- <p>Gets the time to be used when checking this source. The advantage of
- calling this function over calling <code class="function">g_get_monotonic_time()</code> 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 <code class="function">g_get_monotonic_time()</code>.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.13.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.14"></a><h3>is-destroyed?</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:is-destroyed? self))
- </pre></div>
- <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"><pre class="programlisting">
- static gboolean
- idle_callback (gpointer data)
- {
- SomeWidget *self = data;
-
- GDK_THREADS_ENTER ();
- // do stuff with self
- self->idle_id = 0;
- GDK_THREADS_LEAVE ();
-
- return G_SOURCE_REMOVE;
- }
-
- static void
- some_widget_do_stuff_later (SomeWidget *self)
- {
- self->idle_id = g_idle_add (idle_callback, self);
- }
-
- static void
- some_widget_finalize (GObject *object)
- {
- SomeWidget *self = SOME_WIDGET (object);
-
- if (self->idle_id)
- g_source_remove (self->idle_id);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
- }
- </pre></div>
- <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"><pre class="programlisting">
- static gboolean
- idle_callback (gpointer data)
- {
- SomeWidget *self = data;
-
- GDK_THREADS_ENTER ();
- if (!g_source_is_destroyed (g_main_current_source ()))
- {
- // do stuff with self
- }
- GDK_THREADS_LEAVE ();
-
- return FALSE;
- }
- </pre></div>
- <p>Calls to this function from a thread other than the one acquired by the
- <span class="type">GMainContext</span> the <span class="type">GSource</span> is attached to are typically redundant, as the
- source could be destroyed immediately after this function returns. However,
- once a source is destroyed it cannot be un-destroyed, so this function can be
- used for opportunistic checks from any thread.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.14.9"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.15"></a><h3>modify-unix-fd</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:modify-unix-fd self tag new-events))
- </pre></div>
- <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 <code class="function">g_source_add_unix_fd()</code>.
- </p>
- <p>If you want to remove a fd, don't set its event mask to zero.
- Instead, call <code class="function">g_source_remove_unix_fd()</code>.
- </p>
- <p>This API is only intended to be used by implementations of <span class="type">GSource</span>.
- Do not call this API on a <span class="type">GSource</span> that you did not create.
- </p>
- <p>As the name suggests, this function is not available on Windows.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.15.8"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>tag</p></td>
- <td class="parameter_description">
- <p>the tag from <code class="function">g_source_add_unix_fd()</code></p>
- <p>Passed as <code class="code">tag</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>new_events</p></td>
- <td class="parameter_description">
- <p>the new event mask to watch</p>
- <p>Passed as <code class="code">new-events</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.16"></a><h3>query-unix-fd</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:query-unix-fd self tag))
- </pre></div>
- <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 <span class="type">GSource</span>.
- Do not call this API on a <span class="type">GSource</span> that you did not create.
- </p>
- <p>As the name suggests, this function is not available on Windows.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.16.7"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>tag</p></td>
- <td class="parameter_description">
- <p>the tag from <code class="function">g_source_add_unix_fd()</code></p>
- <p>Passed as <code class="code">tag</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.17"></a><h3>ref</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:ref self))
- </pre></div>
- <p>Increases the reference count on a source by one.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.17.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.18"></a><h3>remove-child-source</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:remove-child-source self child-source))
- </pre></div>
- <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 <span class="type">GSource</span>.
- Do not call this API on a <span class="type">GSource</span> that you did not create.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.18.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>child_source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span> previously passed to
- <code class="function">g_source_add_child_source()</code>.</p>
- <p>Passed as <code class="code">child-source</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.19"></a><h3>remove-poll</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:remove-poll self fd))
- </pre></div>
- <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 <span class="type">GSource</span>.
- Do not call this API on a <span class="type">GSource</span> that you did not create.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.19.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>fd</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GPollFD</span> structure previously passed to <code class="function">g_source_add_poll()</code>.</p>
- <p>Passed as <code class="code">fd</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.20"></a><h3>remove-unix-fd</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:remove-unix-fd self tag))
- </pre></div>
- <p>Reverses the effect of a previous call to <code class="function">g_source_add_unix_fd()</code>.
- </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 <span class="type">GSource</span>.
- Do not call this API on a <span class="type">GSource</span> that you did not create.
- </p>
- <p>As the name suggests, this function is not available on Windows.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.20.7"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>tag</p></td>
- <td class="parameter_description">
- <p>the tag from <code class="function">g_source_add_unix_fd()</code></p>
- <p>Passed as <code class="code">tag</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.21"></a><h3>set-callback</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:set-callback self func data notify))
- </pre></div>
- <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. Cast <em class="parameter"><code>func</code></em> with <code class="function">G_SOURCE_FUNC()</code> to avoid warnings about
- incompatible function types.
- </p>
- <p>See [memory management of sources][mainloop-memory-management] 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, such as <code class="function">g_idle_add()</code> or <code class="function">g_timeout_add()</code>.
- </p>
- <p>It is safe to call this function multiple times on a source which has already
- been attached to a context. The changes will take effect for the next time
- the source is dispatched after this call returns.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.21.8"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>the source</p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>func</p></td>
- <td class="parameter_description">
- <p>a callback function</p>
- <p>Passed as <code class="code">func</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>data</p></td>
- <td class="parameter_description">
- <p>the data to pass to callback function</p>
- <p>Passed as <code class="code">data</code></p>
- </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 <code class="constant">NULL</code>.</p>
- <p>Passed as <code class="code">notify</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.22"></a><h3>set-can-recurse</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:set-can-recurse self can-recurse))
- </pre></div>
- <p>Sets whether a source can be called recursively. If <em class="parameter"><code>can_recurse</code></em> is
- <code class="constant">TRUE</code>, 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="id-1.1.59.3.22.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </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>
- <p>Passed as <code class="code">can-recurse</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.23"></a><h3>set-name</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:set-name self name))
- </pre></div>
- <p>Sets a name for the source, used in debugging and profiling.
- The name defaults to <span class="type">NULL</span>.
- </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 <span class="type">GSourceFuncs</span>
- 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 <code class="function">g_source_get_name()</code>; 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="id-1.1.59.3.23.7"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>name</p></td>
- <td class="parameter_description">
- <p>debug name for the source</p>
- <p>Passed as <code class="code">name</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.24"></a><h3>set-priority</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:set-priority self priority))
- </pre></div>
- <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="id-1.1.59.3.24.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>priority</p></td>
- <td class="parameter_description">
- <p>the new priority.</p>
- <p>Passed as <code class="code">priority</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.25"></a><h3>set-ready-time</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:set-ready-time self ready-time))
- </pre></div>
- <p>Sets a <span class="type">GSource</span> 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>It is a no-op to call this function on a <span class="type">GSource</span> which has already been
- destroyed with <code class="function">g_source_destroy()</code>.
- </p>
- <p>This API is only intended to be used by implementations of <span class="type">GSource</span>.
- Do not call this API on a <span class="type">GSource</span> that you did not create.</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.25.9"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </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>
- <p>Passed as <code class="code">ready-time</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.26"></a><h3>set-static-name</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:set-static-name self name))
- </pre></div>
- <p>Undocumented</p>
- <div class="refsect3">
- <a name="id-1.1.59.3.26.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>name</p></td>
- <td class="parameter_description">
- <p></p>
- <p>Passed as <code class="code">name</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.27"></a><h3>unref</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:unref self))
- </pre></div>
- <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="id-1.1.59.3.27.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>source</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.28"></a><h3>source:remove?</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:remove? tag))
- </pre></div>
- <p>Removes the source with the given ID from the default main context. You must
- use <code class="function">g_source_destroy()</code> for sources added to a non-default main context.
- </p>
- <p>The ID of a <span class="type">GSource</span> is given by <code class="function">g_source_get_id()</code>, or will be
- returned by the functions <code class="function">g_source_attach()</code>, <code class="function">g_idle_add()</code>,
- <code class="function">g_idle_add_full()</code>, <code class="function">g_timeout_add()</code>, <code class="function">g_timeout_add_full()</code>,
- <code class="function">g_child_watch_add()</code>, <code class="function">g_child_watch_add_full()</code>, <code class="function">g_io_add_watch()</code>, and
- <code class="function">g_io_add_watch_full()</code>.
- </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 <code class="function">g_idle_add()</code>: 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="id-1.1.59.3.28.7"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>tag</p></td>
- <td class="parameter_description">
- <p>the ID of the source to remove.</p>
- <p>Passed as <code class="code">tag</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.29"></a><h3>source:remove-by-user-data?</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (source:remove-by-user-data? user-data))
- </pre></div>
- <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="id-1.1.59.3.29.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>user_data</p></td>
- <td class="parameter_description">
- <p>the user_data for the callback.</p>
- <p>Passed as <code class="code">user-data</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.59.3.30"></a><h3>source:set-name-by-id</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (source:set-name-by-id tag name))
- </pre></div>
- <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 <code class="function">g_idle_add()</code>, <code class="function">g_timeout_add()</code>, 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 <code class="function">g_idle_add()</code>: 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="id-1.1.59.3.30.7"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>tag</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GSource</span> ID</p>
- <p>Passed as <code class="code">tag</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>name</p></td>
- <td class="parameter_description">
- <p>debug name for the source</p>
- <p>Passed as <code class="code">name</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- </div>
- </div>
- <div class="footer">
- <hr>Generated by GTK-Doc V1.33.1</div>
- </body>
- </html>
|