Re: [Vala] Delegates thread-safe



Hm, interesting, how would I do that?

I have a generator function that uses the delegate as such:

public void generator(GeneratorCallback callback) {
 Thread.create<void*>(() => {
                        Individual? individual = callback();
                        queue.push(individual);
 return null;
}, true);
}

And my delegate is declared as:

delegate Individual GeneratorCallback();


I tried using *owned* in *generator *but it didnt help. It crashes when
calling callback.

Any help?

Regards,
Alexandre

On Thu, Dec 15, 2011 at 16:47, Abderrahim Kitouni <a kitouni gmail com>wrote:

Hello,

            في خ، 15-12-2011 عند 15:42 -0200 ، كتب Alexandre Rosenfeld:
Hey guys,

I was recently creating a program where a delegate is passed around and
then executed inside different threads. The delegate itself was
thread-safe, I wasn't using anything that would cause a problem if it was
called from multiple threads. However the program kept crashing with
memory
violations which were caused by objects that were previously freed.

Before going any further, are you using owned delegates? If not, you
should. (but this may not be the only reason)

HTH,
Abderrahim




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