-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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)
[email protected]              http://www.rastersoft.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlCFvwEACgkQXEZvyfy1ha/m+QCfQzIoKObEBhWIO8mwCPtbjBNI
9I8AoJ2kNDrIRYqRsHFCk4sb6eN/pPyC
=yUo1
-----END PGP SIGNATURE-----

using GLib;

public class test: Object {
	
	public SourceFunc ext_callback;
	
	public async int test_function() {
		
		this.ext_callback = test_function.callback;
		GLib.stdout.printf("Entering async function\n");

#if DO_YIELD
		GLib.stdout.printf("Doing Yield\n");
		yield;
		GLib.stdout.printf("Continuing after Yield\n");
#endif
			
		GLib.stdout.printf("Exiting async function\n");
		return 1;
	}

	public void run_test() {
	
		GLib.stdout.printf("Starting code\n");
	
		test_function.begin( (obj,res) => {
			var val=test_function.end(res);
			GLib.stdout.printf("End callback called %d\n",val);
		});
	
		GLib.stdout.printf("Continuing main function\n");
#if DO_YIELD
		GLib.stdout.printf("Calling test_function.callback\n");
		ext_callback();
		GLib.stdout.printf("Returned from test_function.callback\n");
#endif
	
	}
}

int main(string[] argv) {
	
	
	var tst=new test();
	
	tst.run_test();
	return 0;
}

Attachment: test_async.vala.sig
Description: Binary data

_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to