Re: [Vala] new async gio vapi



On Mon, Sep 14, 2009 at 19:59:09 +0200, lariamat wrote:
Hi all
I wonder how the latest changes to the gio vapi have to be used in a
program. I have no experience with the other async stuff. How can I
connect that to a callback that would handle the GLib.AsyncResult like
in
http://live.gnome.org/Vala/GIOSamples#head-164983820b65aa689b970b193fec6ddc7368179e
? 

Excerpt from the patch: 
- public void read_line_async (int io_priority, GLib.Cancellable?
cancellable, GLib.AsyncReadyCallback callback);
- public unowned string read_line_finish (GLib.AsyncResult _result, out
size_t length) throws GLib.Error;
+ public async unowned string read_line_async (int io_priority,
GLib.Cancellable? cancellable, out size_t length) throws GLib.Error;
+ public unowned string read_line_finish (GLib.AsyncResult _result, out
unowned size_t length) throws GLib.Error;

The old code should still compile, or at least that's what I understood from
yesterday's discussion on IRC.

In addition to that, new syntax for methods, that suspend themselves until an
async result is ready was added by that change. It should work roughly like:

 - declare the method with async modifier.
 - inside the method, you can either
     result = yield another-async-method(params);
   or
     set_callback_on_something(methodname.callback);
     yield;
     obtain_the_result();
   Have a look at the test case in tests/dbus/async.test in the source tree

(that's a DBus stuff, but the syntax is general for anything using
GLib.AsyncResult)

-- 
                                                 Jan 'Bulb' Hudec <bulb ucw cz>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]