Re: [Vala] Threads and closures problem

2011-07-10 Thread Jim Peters
On Thu, January 14, 2010 21:22, JM wrote: Looks like closures and threads are incompatible right now. I came across exactly the same issue when trying to pass a parameter to a thread. The problem is to maintain a reference to the closure which can be released when the closure is no longer

Re: [Vala] Threads and closures problem

2010-01-15 Thread Jan Hudec
On Thu, January 14, 2010 21:22, JM wrote: Hi all Looks like closures and threads are incompatible right now. This is the ccode generated from vala. Of course. You can't just add 'owned' to a delegate parameter and think things will work -- it changes the corresponding C signature by adding

Re: [Vala] Threads and closures problem

2010-01-15 Thread Jan Hudec
On Thu, January 14, 2010 01:12, JM wrote: Hi Łukas Thanks for your reply! This somehow does not work as soon as I add another thread. class HHH : Object { private ThreadFunc f; public void run() { string test = test; try {

Re: [Vala] Threads and closures problem

2010-01-15 Thread JM
Am Freitag, den 15.01.2010, 12:16 +0100 schrieb Jan Hudec: Of course. You can't just add 'owned' to a delegate parameter and think things will work -- it changes the corresponding C signature by adding the destroy notify callback. Hello Jan I didn't realize the incompatibility in the

Re: [Vala] Threads and closures problem

2010-01-14 Thread JM
Hello all Thanks Łukasz for your reply! That explains the behavior. But then, shouldn't a thread also own the thread function or will that lead to other issues? Should the vapi binding be: public static weak Thread create (owned ThreadFunc func, bool joinable) throws ThreadError; instdead of:

Re: [Vala] Threads and closures problem

2010-01-14 Thread JM
Hi all Looks like closures and threads are incompatible right now. This is the ccode generated from vala. VALA: Thread.create( ()= { Thread.usleep(1000); print(in thread : %s \n, test); }, false); CCODE: g_thread_create (__lambda0__gthread_func, _data1_, FALSE, _inner_error_); CCODE (with owned

[Vala] Threads and closures problem

2010-01-13 Thread JM
Hi all I just played around with closures as thread functions. I'm not sure if this example is supposed to work, but at least it compiles. class HHH : Object { public void run() { string test = test; try { Thread.create( ()= {

Re: [Vala] Threads and closures problem

2010-01-13 Thread Łukasz Pankowski
JM interfl...@gmx.net writes: Hi all I just played around with closures as thread functions. I'm not sure if this example is supposed to work, but at least it compiles. class HHH : Object { public void run() { string test = test; try {

Re: [Vala] Threads and closures problem

2010-01-13 Thread JM
Hi Łukas Thanks for your reply! This somehow does not work as soon as I add another thread. class HHH : Object { private ThreadFunc f; public void run() { string test = test; try { f = ()= { print(in thread : %s \n, test);

Re: [Vala] Threads and closures problem

2010-01-13 Thread JM
The problem gets worse, as soon as I use a class variable: class HHH : Object { private ThreadFunc f; public int t; public void run() { t = 4; string test = test; try { f = ()= { Thread.usleep(1000);

Re: [Vala] Threads and closures problem

2010-01-13 Thread JM
If I do the same thing with an Idle, the behavior is significantly different, as the block data is not destroyed as soon as the run() function is left. Why is that? Well working example: class HHH : Object { public void run() { string test = test;