blob: 67de0878776d0cad109e2479b5b8324000f1d4c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>gio.Cancellable</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><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-giobufferedoutputstream.html" title="gio.BufferedOutputStream"><link rel="next" href="class-giodatainputstream.html" title="gio.DataInputStream"></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.Cancellable</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-giobufferedoutputstream.html">Prev</a> </td><th width="60%" align="center">PyGio Class Reference</th><td width="20%" align="right"> <a accesskey="n" href="class-giodatainputstream.html">Next</a></td></tr></table><hr></div><div class="refentry" title="gio.Cancellable"><a name="class-giocancellable"></a><div class="titlepage"></div><div class="refnamediv"><h2>gio.Cancellable</h2><p>gio.Cancellable — Thread-safe Operation Cancellation Stack.</p></div><div class="refsect1" title="Synopsis"><a name="id2918796"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gio.Cancellable</span></span>(<span class="ooclass"><span class="classname"><a class="link" href="class-gobject.html" title="gobject.GObject">gobject.GObject</a></span></span>):
<code class="constructorsynopsis"> <span class="methodname"><a class="link" href="class-giocancellable.html#constructor-giocancellable" title="Constructor">gio.Cancellable</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-giocancellable.html#method-giocancellable--cancel" title="gio.Cancellable.cancel">cancel</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-giocancellable.html#method-giocancellable--get-fd" title="gio.Cancellable.get_fd">get_fd</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-giocancellable.html#method-giocancellable--is-cancelled" title="gio.Cancellable.is_cancelled">is_cancelled</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-giocancellable.html#method-giocancellable--pop-current" title="gio.Cancellable.pop_current">pop_current</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-giocancellable.html#method-giocancellable--push-current" title="gio.Cancellable.push_current">push_current</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-giocancellable.html#method-giocancellable--reset" title="gio.Cancellable.reset">reset</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-giocancellable.html#method-giocancellable--set-error-if-cancelled" title="gio.Cancellable.set_error_if_cancelled">set_error_if_cancelled</a></span>(<span class="methodparam"></span>)</code><br></pre></td></tr></table><pre class="programlisting">
<span class="bold"><strong>Functions</strong></span>
<code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-giocancellable.html#function-gio--cancellable-get-current" title="gio.cancellable_get_current">gio.cancellable_get_current</a></span>(<span class="methodparam"></span>)</code></pre></div><div class="refsect1" title="Ancestry"><a name="id2945357"></a><h2>Ancestry</h2><pre class="synopsis">+-- <a class="link" href="class-gobject.html" title="gobject.GObject">gobject.GObject</a>
+-- <a class="link" href="class-giocancellable.html" title="gio.Cancellable">gio.Cancellable</a>
</pre></div><div class="refsect1" title="Description"><a name="id2897140"></a><h2>Description</h2><p>
The <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
is a thread-safe operation cancellation stack used throughout GIO to allow for
cancellation of synchronous and asynchronous operations.
</p></div><div class="refsect1" title="Constructor"><a name="constructor-giocancellable"></a><h2>Constructor</h2><pre class="programlisting"><code class="constructorsynopsis"> <span class="methodname">gio.Cancellable</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 new
<a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>.
</td></tr></tbody></table><p>
Creates a new <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a> object.
</p><p>
Applications that want to start one or more operations that should be cancellable should create a
<a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
and pass it to the operations.
</p><p>
One <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
can be used in multiple consecutive operations, but not in multiple concurrent operations.
</p></div><div class="refsect1" title="Methods"><a name="id2894890"></a><h2>Methods</h2><div class="refsect2" title="gio.Cancellable.cancel"><a name="method-giocancellable--cancel"></a><h3>gio.Cancellable.cancel</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">cancel</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>
The <code class="methodname">cancel</code>() method will set cancellable to cancelled,
and will emit the "cancelled" signal. (However, see the warning about race conditions
in the documentation for that signal if you are planning to connect to it.)
</p><p>
This function is thread-safe. In other words, you can safely call it from a thread
other than the one running the operation that was passed the cancellable.
</p><p>
The convention within gio is that cancelling an asynchronous operation causes it
to complete asynchronously. That is, if you cancel the operation from the same thread
in which it is running, then the operation's GAsyncReadyCallback will not be invoked
until the application returns to the main loop.
</p></div><div class="refsect2" title="gio.Cancellable.get_fd"><a name="method-giocancellable--get-fd"></a><h3>gio.Cancellable.get_fd</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_fd</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 valid file descriptor. -1 if the file descriptor
is not supported, or on errors.</td></tr></tbody></table><p>
The <code class="methodname">get_fd</code>() method gets the file descriptor
for a cancellable job. This can be used to implement cancellable operations
on Unix systems. The returned fd will turn readable when cancellable is cancelled.
</p></div><div class="refsect2" title="gio.Cancellable.is_cancelled"><a name="method-giocancellable--is-cancelled"></a><h3>gio.Cancellable.is_cancelled</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">is_cancelled</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 cancellable is cancelled,
<code class="literal">False</code> if called with <code class="literal">None</code> or if
item is not cancelled. </td></tr></tbody></table><p>
The <code class="methodname">get_fd</code>() method gets the file descriptor
for a cancellable job. This can be used to implement cancellable operations
on Unix systems. The returned fd will turn readable when cancellable is cancelled.
</p></div><div class="refsect2" title="gio.Cancellable.pop_current"><a name="method-giocancellable--pop-current"></a><h3>gio.Cancellable.pop_current</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">pop_current</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>
The <code class="methodname">pop_current</code>() method pops cancellable off
the cancellable stack (verifying that cancellable is on the top of the stack).
</p></div><div class="refsect2" title="gio.Cancellable.push_current"><a name="method-giocancellable--push-current"></a><h3>gio.Cancellable.push_current</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">push_current</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>
The <code class="methodname">push_current</code>() method pushes cancellable onto
the cancellable stack. The current cancllable can then be recieved using
<code class="methodname"><a class="link" href="class-giocancellable.html#function-gio--cancellable-get-current" title="gio.cancellable_get_current">gio.cancellable_get_current</a></code>().
</p></div><div class="refsect2" title="gio.Cancellable.reset"><a name="method-giocancellable--reset"></a><h3>gio.Cancellable.reset</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">reset</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>
The <code class="methodname">reset</code>() method resets cancellable to its uncancelled state.
</p></div><div class="refsect2" title="gio.Cancellable.set_error_if_cancelled"><a name="method-giocancellable--set-error-if-cancelled"></a><h3>gio.Cancellable.set_error_if_cancelled</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_error_if_cancelled</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 cancellable was cancelled,
<code class="literal">False</code> if it was not.</td></tr></tbody></table><p>
The <code class="methodname">set_error_if_cancelled</code>() method, if the cancellable
is cancelled, sets the error to notify that the operation was cancelled.
</p></div></div><div class="refsect1" title="Functions"><a name="id2927444"></a><h2>Functions</h2><div class="refsect2" title="gio.cancellable_get_current"><a name="function-gio--cancellable-get-current"></a><h3>gio.cancellable_get_current</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">cancellable_get_current</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 <a class="link" href="class-giocancellable.html" title="gio.Cancellable"><code class="classname">gio.Cancellable</code></a>
from the top of the stack, or <code class="literal">None</code> if the stack is empty.</td></tr></tbody></table><p>
The <code class="methodname">cancellable_get_current</code>() function gets the top cancellable from the stack.
</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-giobufferedoutputstream.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-giodatainputstream.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gio.BufferedOutputStream </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> gio.DataInputStream</td></tr></table></div></body></html>
|