Re: [Vala] Combining async methods with external processes



you are using coroutines which are not designed to "run stuff in background".

coroutines are designed to run collaborative code which hangs if one of the
parts doesn't pass the token when necessary.

You have to use threads, or an idle task if you have a mainloop.

On 11/19/10 08:34, James Moschou wrote:
Hello,

I want to perform a series of tasks one after the other, but in the
background. So I have:

async bool perform_tasks () {
     bool result = yield task1 ();
     if (result)
         result = yield task2 ();
     if (result)
         result = yield task3 ();

     Idle.add (perform_tasks.callback)
     yield;
     return result;
}

more or less.

One of the tasks however spawns a new process, and I'm not sure how
the callback from this process is supposed to fit into Vala's way of
doing async programming, i.e. Process.spawn_async_with_pipes () isn't
actually an "async" method.

How would I do this, am I making things too complicated?

Cheers,
James
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list





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