611961882563e0661418c2f8f918fa981233c414
[platform/upstream/pygobject2.git] / docs / html / class-giosimpleasyncresult.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>gio.SimpleAsyncResult</title><link rel="stylesheet" type="text/css" href="style.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="PyGObject Reference Manual"><link rel="up" href="gio-class-reference.html" title="PyGio Class Reference"><link rel="prev" href="class-gioseekable.html" title="gio.Seekable"><link rel="next" href="class-giothemedicon.html" title="gio.ThemedIcon"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">gio.SimpleAsyncResult</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-gioseekable.html">Prev</a> </td><th width="60%" align="center">PyGio Class Reference</th><td width="20%" align="right"> <a accesskey="n" href="class-giothemedicon.html">Next</a></td></tr></table><hr></div><div class="refentry" title="gio.SimpleAsyncResult"><a name="class-giosimpleasyncresult"></a><div class="titlepage"></div><div class="refnamediv"><h2>gio.SimpleAsyncResult</h2><p>gio.SimpleAsyncResult — Simple asynchronous results implementation.</p></div><div class="refsect1" title="Synopsis"><a name="id527016"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gio.SimpleAsyncResult</span></span>(<span class="ooclass"><span class="classname"><a class="link" href="class-gobject.html" title="gobject.GObject">gobject.GObject</a></span></span>):
2 <code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--complete" title="gio.SimpleAsyncResult.complete">complete</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--complete-in-idle" title="gio.SimpleAsyncResult.complete_in_idle">complete_in_idle</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--get-op-res-gboolean" title="gio.SimpleAsyncResult.get_op_res_gboolean">get_op_res_gboolean</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--get-op-res-gssize" title="gio.SimpleAsyncResult.get_op_res_gssize">get_op_res_gssize</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--propagate-error" title="gio.SimpleAsyncResult.propagate_error">propagate_error</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--set-handle-cancellation" title="gio.SimpleAsyncResult.set_handle_cancellation">set_handle_cancellation</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>handle_cancellation</code></strong></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--set-op-res-gboolean" title="gio.SimpleAsyncResult.set_op_res_gboolean">set_op_res_gboolean</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>op_res</code></strong></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--set-op-res-gssize" title="gio.SimpleAsyncResult.set_op_res_gssize">set_op_res_gssize</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>op_res</code></strong></span></span>)</code><br></pre></td></tr></table></div><div class="refsect1" title="Ancestry"><a name="id527227"></a><h2>Ancestry</h2><pre class="synopsis">+-- <a class="link" href="class-gobject.html" title="gobject.GObject">gobject.GObject</a>
3   +-- <a class="link" href="class-giosimpleasyncresult.html" title="gio.SimpleAsyncResult">gio.SimpleAsyncResult</a>
4 </pre></div><div class="refsect1" title="Implemented Interface"><a name="id527253"></a><h2>Implemented Interface</h2><p>
5             <a class="link" href="class-giosimpleasyncresult.html" title="gio.SimpleAsyncResult"><code class="classname">gio.SimpleAsyncResult</code></a> implements
6             <a class="link" href="class-gioasyncresult.html" title="gio.AsyncResult"><code class="classname">gio.AsyncResult</code></a>.
7         </p></div><div class="refsect1" title="Description"><a name="id527278"></a><h2>Description</h2><p>
8             Implements <a class="link" href="class-gioasyncresult.html" title="gio.AsyncResult"><code class="classname">gio.AsyncResult</code></a>
9             for simple cases. Most of the time, this will be all an application needs, and will be used transparently
10             Because of this, GSimpleAsyncResult is used throughout GIO for handling asynchronous functions.            
11         </p><p>
12             <a class="link" href="class-giosimpleasyncresult.html" title="gio.SimpleAsyncResult"><code class="classname">gio.SimpleAsyncResult</code></a>
13             handles GAsyncReadyCallbacks, error reporting, operation cancellation and the final state of an
14             operation, completely transparent to the application. Results can be returned as a pointer e.g.
15             for functions that return data that is collected asynchronously, a boolean value for checking the
16             success or failure of an operation, or a gssize for operations which return the number of bytes modified
17             by the operation; all of the simple return cases are covered. 
18         </p><p>
19             Most of the time, an application will not need to know of the details of this API; it is handled
20             transparently, and any necessary operations are handled by GAsyncResult's interface. However, if
21             implementing a new GIO module, for writing language bindings, or for complex applications that need
22             better control of how asynchronous operations are completed, it is important to understand this functionality. 
23         </p><p>
24             <a class="link" href="class-giosimpleasyncresult.html" title="gio.SimpleAsyncResult"><code class="classname">gio.SimpleAsyncResult</code></a>
25             are tagged with the calling function to ensure that asynchronous functions and
26             their finishing functions are used together correctly. 
27         </p><p>
28             An asynchronous operation can be made to ignore a cancellation event by calling
29             <code class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--set-handle-cancellation" title="gio.SimpleAsyncResult.set_handle_cancellation">gio.SimpleAsyncResult.set_handle_cancellation</a></code>()
30             with a
31             <a class="link" href="class-gioasyncresult.html" title="gio.AsyncResult"><code class="classname">gio.AsyncResult</code></a>
32             for the operation and <code class="literal">False</code>. This is useful for operations that are dangerous to cancel,
33             such as close (which would cause a leak if cancelled before being run). 
34         </p><p>
35             <a class="link" href="class-gioasyncresult.html" title="gio.AsyncResult"><code class="classname">gio.AsyncResult</code></a>
36             can integrate into GLib's event loop, GMainLoop, or it can use GThreads if available.
37             <code class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--complete" title="gio.SimpleAsyncResult.complete">gio.SimpleAsyncResult.complete</a></code>()
38             will finish an I/O task directly within the main event loop.
39             <code class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--complete-in-idle" title="gio.SimpleAsyncResult.complete_in_idle">gio.SimpleAsyncResult.complete_in_idle</a></code>()
40             will integrate the I/O task into the main event loop as an idle function.
41             
42         </p><p>
43             To set the results of an asynchronous function,
44             <code class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--set-op-res-gboolean" title="gio.SimpleAsyncResult.set_op_res_gboolean">gio.SimpleAsyncResult.set_op_res_gboolean</a></code>(), and
45             <code class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--set-op-res-gssize" title="gio.SimpleAsyncResult.set_op_res_gssize">gio.SimpleAsyncResult.set_op_res_gssize</a></code>()
46             are provided, setting the operation's result to a gboolean, or gssize, respectively. 
47         </p><p>
48             Likewise, to get the result of an asynchronous function,
49             <code class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--get-op-res-gboolean" title="gio.SimpleAsyncResult.get_op_res_gboolean">gio.SimpleAsyncResult.get_op_res_gboolean</a></code>() and
50             <code class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--get-op-res-gssize" title="gio.SimpleAsyncResult.get_op_res_gssize">gio.SimpleAsyncResult.get_op_res_gssize</a></code>()
51             are provided, getting the operation's result as a gboolean and gssize, respectively.
52         </p></div><div class="refsect1" title="Methods"><a name="id527441"></a><h2>Methods</h2><div class="refsect2" title="gio.SimpleAsyncResult.complete"><a name="method-giosimpleasyncresult--complete"></a><h3>gio.SimpleAsyncResult.complete</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">complete</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody></tbody></table><p>
53                 The <code class="methodname">complete</code>() method completes an asynchronous I/O job.
54                 Must be called in the main thread, as it invokes the callback that should be called
55                 in the main thread. If you are in a different thread use
56                 <code class="methodname"><a class="link" href="class-giosimpleasyncresult.html#method-giosimpleasyncresult--complete-in-idle" title="gio.SimpleAsyncResult.complete_in_idle">gio.SimpleAsyncResult.complete_in_idle</a></code>().
57             </p></div><div class="refsect2" title="gio.SimpleAsyncResult.complete_in_idle"><a name="method-giosimpleasyncresult--complete-in-idle"></a><h3>gio.SimpleAsyncResult.complete_in_idle</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">complete_in_idle</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody></tbody></table><p>
58                 The <code class="methodname">complete_in_idle</code>() method completes an asynchronous
59                 function in the main event loop using an idle function.
60             </p></div><div class="refsect2" title="gio.SimpleAsyncResult.get_op_res_gboolean"><a name="method-giosimpleasyncresult--get-op-res-gboolean"></a><h3>gio.SimpleAsyncResult.get_op_res_gboolean</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">get_op_res_gboolean</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> if the operation's result was
61                     <code class="literal">True</code>, <code class="literal">False</code> if the operation's result
62                     was <code class="literal">False</code>. 
63                     </td></tr></tbody></table><p>
64                 The <code class="methodname">get_op_res_gboolean</code>() method gets the operation
65                 result boolean from within the asynchronous result.
66             </p></div><div class="refsect2" title="gio.SimpleAsyncResult.get_op_res_gssize"><a name="method-giosimpleasyncresult--get-op-res-gssize"></a><h3>gio.SimpleAsyncResult.get_op_res_gssize</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">get_op_res_gssize</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a gssize returned from the asynchronous function.
67                     </td></tr></tbody></table><p>
68                 The <code class="methodname">get_op_res_gssize</code>() method gets a gssize
69                 from the asynchronous result.
70             </p></div><div class="refsect2" title="gio.SimpleAsyncResult.propagate_error"><a name="method-giosimpleasyncresult--propagate-error"></a><h3>gio.SimpleAsyncResult.propagate_error</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">propagate_error</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> if the error was propegated
71                     to dest. <code class="literal">False</code> otherwise. 
72                     </td></tr></tbody></table><p>
73                 The <code class="methodname">propagate_error</code>() method propagates an error
74                 from within the simple asynchronous result to a given destination.
75             </p></div><div class="refsect2" title="gio.SimpleAsyncResult.set_handle_cancellation"><a name="method-giosimpleasyncresult--set-handle-cancellation"></a><h3>gio.SimpleAsyncResult.set_handle_cancellation</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">set_handle_cancellation</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>handle_cancellation</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>handle_cancellation</code></strong> :</span></p></td><td>a boolean.
76                   </td></tr></tbody></table><p>
77                 The <code class="methodname">set_handle_cancellation</code>() method sets whether
78                 to handle cancellation within the asynchronous operation.
79             </p></div><div class="refsect2" title="gio.SimpleAsyncResult.set_op_res_gboolean"><a name="method-giosimpleasyncresult--set-op-res-gboolean"></a><h3>gio.SimpleAsyncResult.set_op_res_gboolean</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">set_op_res_gboolean</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>op_res</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>op_res</code></strong> :</span></p></td><td>a boolean.
80                   </td></tr></tbody></table><p>
81                 The <code class="methodname">set_op_res_gboolean</code>() method sets the operation
82                 result to a boolean within the asynchronous result.
83             </p></div><div class="refsect2" title="gio.SimpleAsyncResult.set_op_res_gssize"><a name="method-giosimpleasyncresult--set-op-res-gssize"></a><h3>gio.SimpleAsyncResult.set_op_res_gssize</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">set_op_res_gssize</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>op_res</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>op_res</code></strong> :</span></p></td><td>a gssize.
84                   </td></tr></tbody></table><p>
85                 The <code class="methodname">set_op_res_gssize</code>() method sets the operation
86                 result within the asynchronous result to the given op_res.
87             </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="class-gioseekable.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="gio-class-reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="class-giothemedicon.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gio.Seekable </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> gio.ThemedIcon</td></tr></table></div></body></html>