1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
5 <refentry id="class-gioasyncresult">
7 <refname>gio.AsyncResult</refname>
8 <refpurpose>Asynchronous Function Results.</refpurpose>
12 <title>Synopsis</title>
14 <classsynopsis language="python">
15 <ooclass><classname>gio.AsyncResult</classname></ooclass>
16 <ooclass><classname><link linkend="class-gobjectginterface">gobject.GInterface</link></classname></ooclass>
18 <methodsynopsis language="python">
19 <methodname><link linkend="method-gioasyncresult--get-source-object">get_source_object</link></methodname>
20 <methodparam></methodparam>
28 <title>Ancestry</title>
30 <synopsis>+-- <link linkend="class-gobjectginterface">gobject.GInterface</link>
31 +-- <link linkend="class-gioasyncresult">gio.AsyncResult</link>
37 <title>Prerequisites</title>
39 <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link> is required by
40 <link linkend="class-gobject"><classname>gobject.GObject</classname></link>.
45 <title>Known Implementation</title>
47 <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link> is implemented by
48 <link linkend="class-giosimpleasyncresult"><classname>gio.SimpleAsyncResult</classname></link>.
53 <title>Description</title>
56 <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>
57 provides a base class for implementing asynchronous function results.
60 Asynchronous operations are broken up into two separate operations which are chained
61 together by a GAsyncReadyCallback. To begin an asynchronous operation, provide a
62 GAsyncReadyCallback to the asynchronous function. This callback will be triggered when
63 the operation has completed, and will be passed a GAsyncResult instance filled with the
64 details of the operation's success or failure, the object the asynchronous function was
65 started for and any error codes returned. The asynchronous callback function is then expected
66 to call the corresponding "_finish()" function with the object the function was called for,
67 and the <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>
68 instance, and optionally, an error to grab any error conditions that may have occurred.
71 The purpose of the "_finish()" function is to take the generic result of type GAsyncResult and
72 return the specific result that the operation in question yields (e.g. a
73 <link linkend="class-giofileenumerator"><classname>gio.FileEnumerator</classname></link>
74 for a "enumerate children" operation). If the result or error status of the operation is not needed,
75 there is no need to call the "_finish()" function, GIO will take care of cleaning up the result and error
76 information after the GAsyncReadyCallback returns. It is also allowed to take a reference to the
77 <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>
78 and call "_finish()" later.
81 The callback for an asynchronous operation is called only once, and is always called, even
82 in the case of a cancelled operation. On cancellation the result is a gio.ERROR_CANCELLED error.
85 Some ascynchronous operations are implemented using synchronous calls. These are run in a
86 separate thread, if GThread has been initialized, but otherwise they are sent to the Main Event
87 Loop and processed in an idle function. So, if you truly need asynchronous operations, make
88 sure to initialize GThread.
93 <title>Methods</title>
95 <refsect2 id="method-gioasyncresult--get-source-object">
96 <title>gio.AsyncResult.get_source_object</title>
98 <programlisting><methodsynopsis language="python">
99 <methodname>get_source_object</methodname>
100 <methodparam></methodparam>
101 </methodsynopsis></programlisting>
105 <term><emphasis>Returns</emphasis> :</term>
106 <listitem><simpara>the source object for the res.
107 </simpara></listitem>
112 The <methodname>get_source_object</methodname>() method gets the source object
113 from a <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>