Re: [Vala] idea for vala performance optimization
- From: Al Thomas <astavale yahoo co uk>
- To: Vala List <vala-list gnome org>
- Subject: Re: [Vala] idea for vala performance optimization
- Date: Sat, 21 Nov 2015 15:56:48 +0000 (UTC)
________________________________
From: Michele Dionisio <michele dionisio gmail com>
Sent: Saturday, 21 November 2015, 14:13
Subject: Re: [Vala] idea for vala performance optimization
It is true the gcc nested function does not manage any reference counting
to the object or manage any garbege collector.
Maintaining the context data is fundamental to a closure.
This allows a closure to be useful as a callback because, although the
callback has gone out of the enclosing context's scope, the enclosing context
is still available within the closure. So GCC nested functions do not help you here.
You seem to be confused between closures and co-routines:
but thinks about this quite common scenario:>
async function1() {
int a=1;
yield function2();
yield function3();
}
when function1 is converted in C we can split functio1 in more than one neasted function that all can access
to the local variable 'a';
something like:
function1() {
int a=1;
void function1_2() {
}
void function1_1() {
function1_2();
}
function2( function1_1() );
}
now 'a' is visible to all. So the continuation can be implemented without
problem because function1 is not terminated before calling function1_1 and
function1_2 and there is no copy of memory.
If you are looking to learn about co-routines in Vala take a look at:
http://valajournal.blogspot.co.uk/2011/07/generators-in-vala.html
https://wiki.gnome.org/Projects/Vala/AsyncSamples
You use a class as the enclosing context.
Regards,
Al
[
Date Prev][
Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]