Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

GLib::AsyncInitable

module GLib::AsyncInitable

This is the asynchronous version of GLib::Initable; it behaves the same in all ways except that initialization is asynchronous. For more details see the descriptions on GLib::Initable.

A class may implement both the GLib::Initable and GLib::AsyncInitable interfaces.

Instance Methods

init_async(io_priority = GLib::PRIORITY_DEFAULT, cancellable = nil){ |result| }

Starts asynchronous initialization of the object implementing the interface. This must be done before any real use of the object after initial construction. If the object also implements GLib::Initable you can optionally call GLib::Initable#init instead.

When the initialization is finished, a GLib::AsyncResult will be yielded. You can then call GLib::AsyncInitable#init_finish to get the result of the initialization.

Implementations may also support cancellation. If cancellable is not nil, then initialization can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, GLib::IO::CancelledError will be raised. If cancellable is not nil, and the object doesn’t support cancellable initialization, the error GLib::IO::NotSupportedError will be raised.

If this function is not called, or raises an error, then all operations on the object should fail, generally raising GLib::IO::NotInitializedError.

Implementations of this method must be idempotent, that is, multiple calls to this function with the same argument should return the same results. Only the first call initializes the object; further calls return the result of the first call. This is so that it’s safe to implement the singleton pattern in the GLib::Object constructor function.

For classes that also support the GLib::Initable interface, the default implementation of this method will run the GLib::Initable#init function in a thread, so if you want to support asynchronous initialization via threads, just implement the GLib::AsyncInitable interface without overriding any interface methods.

Since 2.22

init_finish(result)

Finishes asynchronous initialization and returns the result. See GLib::AsyncInitable#init_async.

A GLib::IO::Error is raised if this initable couldn’t be initialized.

Since 2.22

initialize_finish(result)
Same as Glib::Initable#init_finish.
Last modified:2010/12/27 21:59:23
Keyword(s):
References:[Ruby/GIO] [index-ruby-glib2] [index-ruby-gio2] [GLib::AsyncInitable]