Re: [Vala] Combining async methods with external processes



I just thought the async/yield methodology was an elegant way of
chaining together multiple background tasks, but are you saying that
it's not suited to what I want and I should do it all with threads and
hand-written callbacks?

On 19 November 2010 22:55, pancake <pancake youterm com> wrote:
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


_______________________________________________
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]