Re: [Vala] Bug in async methods?
- From: rastersoft <raster rastersoft com>
- To: Jim Nelson <jim yorba org>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Bug in async methods?
- Date: Tue, 23 Oct 2012 00:19:36 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Yes, you are right: I created a main loop, called run(), and the
callback got called.
Anyway, I don't understand why is not possible to ensure that the end
callback gets called even without a main loop :?
Thanks!
El 23/10/12 00:03, Jim Nelson escribió:
For async to work properly, you must run the GLib MainLoop. MainLoop is where your async closure for
test_function.begin() is called. It's where all callbacks are scheduled,
actually.
The only reason this works is that in the case of DO_YIELD you stash
the test_function.callback and then call it back. That's why you're
seeing "End callback called 1".
A better way to do this is to (a) get rid of ext_callback and (b) call
"new GLib.MainLoop().run()" right before the "return 0" in main().
Without actually modifying the code (i.e. I'm doing this off the top of
my head), that should work.
-- Jim
On Mon, Oct 22, 2012 at 2:47 PM, rastersoft <raster rastersoft com> wrote:
Hi all:
I was working with async methods, and found something odd: if I call an
async method, but, for whatever reason, I never call YIELD inside, the
end callback function is never called.
I attach an example: by compiling it with
valac -D DO_YIELD -o test_async test_async.vala --pkg=gio-2.0
will do a YIELD inside the async function. But when compiled with
valac -o test_async test_async.vala --pkg=gio-2.0
will not. In the former case you can see how "End callback called 1" is
printed, because the callback for the end is called; but in the later,
it's not printed.
Is that a bug? If not, why does it work that way?
Thanks.
- --
Nos leemos
RASTER (Linux user #228804)
raster rastersoft com http://www.rastersoft.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
iEYEARECAAYFAlCFxngACgkQXEZvyfy1ha/qbgCdEaOkBSyLpQFLgnldBkpo2v4C
FlIAnRy2zdJBUIgC5IfgXbvKEcGg8wAv
=OnLX
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]