Evd.Deferred

Fields

None

Methods

class

new (source_object, cancellable, tag)

complete ()

complete_in_idle ()

get_promise ()

ref ()

set_result_boolean (arg1)

set_result_pointer (data, data_free_func)

set_result_size (size)

take_result_error (error)

unref ()

Details

class Evd.Deferred

An opaque structure that represents a deferred object.

classmethod new(source_object, cancellable, tag)
Parameters:
Returns:

A new Evd.Deferred, to be freed with Evd.Deferred.unref()

Return type:

Evd.Deferred

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 on Evd.Promise, which is a Gio.AsyncResult, all the functionality except the ability to set the result and complete the operation. This way, the Evd.Promise can be made public to the application, while only the Evd.Deferred object is kept private in the implementation as with Gio.SimpleAsyncResult.

An Evd.Deferred and its associated Evd.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 with Evd.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:

Evd.Promise

Retrieves the promise object associated with the deferred.

ref()
Returns:

The same Evd.Deferred object

Return type:

Evd.Deferred

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() or Evd.Deferred.complete_in_idle() should be called after for that purpose.

set_result_pointer(data, data_free_func)
Parameters:

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() or Evd.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() or Evd.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 a GLib.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() or Evd.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.