Evd.Deferred¶
Fields¶
None
Methods¶
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Evd.Deferred¶
An opaque structure that represents a deferred object.
- classmethod new(source_object, cancellable, tag)¶
- Parameters:
source_object (
GObject.Object
orNone
) – TheGObject.Object
performing the async operation, orNone
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
object, orNone
tag (
object
orNone
) – An arbitrary pointer identifying the async operation, orNone
- Returns:
A new
Evd.Deferred
, to be freed withEvd.Deferred.unref
()- Return type:
Creates a new deferred object to track the execution of an asynchronous operation. It works like
Gio.SimpleAsyncResult
, but with some important differences.Evd.Deferred
does not represent itself the result of the asynchronous operation. Instead, it delegates onEvd.Promise
, which is aGio.AsyncResult
, all the functionality except the ability to set the result and complete the operation. This way, theEvd.Promise
can be made public to the application, while only theEvd.Deferred
object is kept private in the implementation as withGio.SimpleAsyncResult
.An
Evd.Deferred
and its associatedEvd.Promise
are bound together so that only a deferred object can resolve or reject its associated promise. The promise of a deferred object can be obtained withEvd.Deferred.get_promise
().
- complete()¶
Completes the asynchronous operation represented by the deferred object, immediately calling all the listener callbacks added to the associated
Evd.Promise
object.This method must not be used if the operation is completed on the same event loop cycle. For those cases,
Evd.Deferred.complete_in_idle
() is provided.
- complete_in_idle()¶
Works as
Evd.Deferred.complete
(), but defers the actual completion to the next event loop cycle.
- get_promise()¶
- Returns:
The
Evd.Promise
, owned by the deferred object- Return type:
Retrieves the promise object associated with the deferred.
- ref()¶
- Returns:
The same
Evd.Deferred
object- Return type:
Increases the reference count of the deferred object.
- set_result_boolean(arg1)¶
- Parameters:
arg1 (
bool
) –
Sets the result of the asynchronous operation as a boolean value.
This method does not completes the operation.
Evd.Deferred.complete
() orEvd.Deferred.complete_in_idle
() should be called after for that purpose.
- set_result_pointer(data, data_free_func)¶
- Parameters:
data (
object
orNone
) – The result of the async operation as aobject
data_free_func (
GLib.DestroyNotify
orNone
) –GLib.DestroyNotify
callback to free data, orNone
Sets the result of the asynchronous operation as an arbitrary pointer of data. data_free_func, if provided, will be called when data is no longer used.
This method does not completes the operation.
Evd.Deferred.complete
() orEvd.Deferred.complete_in_idle
() should be called after for that purpose.
- set_result_size(size)¶
- Parameters:
size (
int
) – The result of the async operation as a gssize
Sets the result of the asynchronous operation as a long signed integer, useful for size results.
This method does not completes the operation.
Evd.Deferred.complete
() orEvd.Deferred.complete_in_idle
() should be called after for that purpose.
- take_result_error(error)¶
- Parameters:
error (
GLib.Error
) – The result of the async operation as aGLib.Error
Sets the result of the asynchronous operation as an error, indicating that the operation failed. The deferred object takes ownership of error.
This method does not completes the operation.
Evd.Deferred.complete
() orEvd.Deferred.complete_in_idle
() should be called after for that purpose.
- unref()¶
Decreases the reference count of the deferred. If it reaches zero, the object is destroyed and all its memory released.