Class: Gio::SimpleAsyncResult

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#check_cancellable=(check_cancellable) ⇒ nil

Sets a #GCancellable to check before dispatching results.

This function has one very specific purpose: the provided cancellable is checked at the time of g_simple_async_result_propagate_error() If it is cancelled, these functions will return an “Operation was cancelled” error (%G_IO_ERROR_CANCELLED).

Implementors of cancellable asynchronous functions should use this in order to provide a guarantee to their callers that cancelling an async operation will reliably result in an error being returned for that operation (even if a positive result for the operation has already been sent as an idle to the main context to be dispatched).

The checking described above is done regardless of any call to the unrelated g_simple_async_result_set_handle_cancellation() function.

Parameters:

  • check_cancellable (Gio::Cancellable)

    a #GCancellable to check, or nil to unset

Returns:

  • (nil)

#completenil

Completes an asynchronous I/O job immediately. Must be called in the thread where the asynchronous result was to be delivered, as it invokes the callback directly. If you are in a different thread use g_simple_async_result_complete_in_idle().

Calling this function takes a reference to simple for as long as is needed to complete the call.

Returns:

  • (nil)

#complete_in_idlenil

Completes an asynchronous function in an idle handler in the

thread-default main context][g-main-context-push-thread-default

of the thread that simple was initially created in (and re-pushes that context around the invocation of the callback).

Calling this function takes a reference to simple for as long as is needed to complete the call.

Returns:

  • (nil)

#from_error=(error) ⇒ nil

Sets the result from a #GError.

Parameters:

  • error (GLib::Error)

    #GError.

Returns:

  • (nil)

#handle_cancellation=(handle_cancellation) ⇒ nil

Sets whether to handle cancellation within the asynchronous operation.

This function has nothing to do with g_simple_async_result_set_check_cancellable(). It only refers to the #GCancellable passed to g_simple_async_result_run_in_thread().

Parameters:

  • handle_cancellation (TrueClass)

    a #gboolean.

Returns:

  • (nil)

#new(source_object, callback, user_data, source_tag) ⇒ Gio::SimpleAsyncResult

Creates a GSimple::AsyncResult.

The common convention is to create the GSimple::AsyncResult in the function that starts the asynchronous operation and use that same function as the source_tag.

If your operation supports cancellation with #GCancellable (which it probably should) then you should provide the user’s cancellable to g_simple_async_result_set_check_cancellable() immediately after this function returns.

Parameters:

  • source_object (GObject::Object)

    a #GObject, or nil.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback.

  • user_data (GObject)

    user data passed to callback.

  • source_tag (GObject)

    the asynchronous function.

Returns:

#new_error(source_object, callback, user_data, domain, code, format, array) ⇒ Gio::SimpleAsyncResult

Creates a new GSimple::AsyncResult with a set error.

Parameters:

  • source_object (GObject::Object)

    a #GObject, or nil.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback.

  • user_data (GObject)

    user data passed to callback.

  • domain (GLib::Quark)

    a #GQuark.

  • code (Integer)

    an error code.

  • format (String)

    a string with format characters.

  • array (Array)

    a list of values to insert into format.

Returns:

#new_from_error(source_object, callback, user_data, error) ⇒ Gio::SimpleAsyncResult

Creates a GSimple::AsyncResult from an error condition.

Parameters:

  • source_object (GObject::Object)

    a #GObject, or nil.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback.

  • user_data (GObject)

    user data passed to callback.

  • error (GLib::Error)

    a #GError

Returns:

#new_take_error(source_object, callback, user_data, error) ⇒ Gio::SimpleAsyncResult

Creates a GSimple::AsyncResult from an error condition, and takes over the caller’s ownership of error, so the caller does not need to free it anymore.

Parameters:

  • source_object (GObject::Object)

    a #GObject, or nil

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback

  • user_data (GObject)

    user data passed to callback

  • error (GLib::Error)

    a #GError

Returns:

#op_res_gbooleanTrueClass

Gets the operation result boolean from within the asynchronous result.

Returns:

  • (TrueClass)

    true if the operation’s result was true, false if the operation’s result was false.

#op_res_gboolean=(op_res) ⇒ nil

Sets the operation result to a boolean within the asynchronous result.

Parameters:

  • op_res (TrueClass)

    a #gboolean.

Returns:

  • (nil)

#op_res_gpointerGObject

Gets a pointer result as returned by the asynchronous function.

Returns:

  • (GObject)

    a pointer from the result.

#op_res_gssizeGio::gssize

Gets a gssize from the asynchronous result.

Returns:

  • (Gio::gssize)

    a gssize returned from the asynchronous function.

#op_res_gssize=(op_res) ⇒ nil

Sets the operation result within the asynchronous result to the given op_res.

Parameters:

  • op_res (Gio::gssize)

    a #gssize.

Returns:

  • (nil)

#propagate_errorTrueClass

Propagates an error from within the simple asynchronous result to a given destination.

If the #GCancellable given to a prior call to g_simple_async_result_set_check_cancellable() is cancelled then this function will return true with dest set appropriately.

Returns:

  • (TrueClass)

    true if the error was propagated to dest. false otherwise.

#run_in_thread(func, io_priority, cancellable) ⇒ nil

Runs the asynchronous job in a separate thread and then calls g_simple_async_result_complete_in_idle() on simple to return the result to the appropriate main loop.

Calling this function takes a reference to simple for as long as is needed to run the job and report its completion.

Parameters:

  • func (Gio::SimpleAsyncThreadFunc)

    a GSimple::AsyncThreadFunc.

  • io_priority (Integer)

    the io priority of the request.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

Returns:

  • (nil)

#set_error(domain, code, format, array) ⇒ nil

Sets an error within the asynchronous result without a #GError.

Parameters:

  • domain (GLib::Quark)

    a #GQuark (usually #G_IO_ERROR).

  • code (Integer)

    an error code.

  • format (String)

    a formatted error reporting string.

  • array (Array)

    a list of variables to fill in format.

Returns:

  • (nil)

#set_error_va(domain, code, format, args) ⇒ nil

Sets an error within the asynchronous result without a #GError. Unless writing a binding, see g_simple_async_result_set_error().

Parameters:

  • domain (GLib::Quark)

    a #GQuark (usually #G_IO_ERROR).

  • code (Integer)

    an error code.

  • format (String)

    a formatted error reporting string.

  • args (Gio::va_list)

    va_list of arguments.

Returns:

  • (nil)

#set_op_res_gpointer(op_res, destroy_op_res) ⇒ nil

Sets the operation result within the asynchronous result to a pointer.

Parameters:

  • op_res (GObject)

    a pointer result from an asynchronous function.

  • destroy_op_res (GLib::DestroyNotify)

    a GDestroy::Notify function.

Returns:

  • (nil)

#source_tagGObject

Gets the source tag for the GSimple::AsyncResult.

Returns:

  • (GObject)

    a #gpointer to the source object for the GSimple::AsyncResult.

#take_error(error) ⇒ nil

Sets the result from error, and takes over the caller’s ownership of error, so the caller does not need to free it any more.

Parameters:

  • error (GLib::Error)

    a #GError

Returns:

  • (nil)