Re: [Vala] Threads and async (was: Threads and closures problem)



Am Donnerstag, den 14.01.2010, 01:27 +0100 schrieb Jiří Zárevúcky:
Michael 'Mickey' Lauer píše v Čt 14. 01. 2010 v 00:48 +0100:
Jörn's mail about threads and closures reminded me about a problem I
wanted to highlight here.

The addition of async functions in Vala is a very great feature, however
I wonder how this could work with multiple threads? As far as I know,
the continuation is scheduled to be an idle callback against the main
context, right? If so, then this would mean that an async functions in a
thread B would only run in the B-context until the first 'yield',
afterwards it would continue to run in the A-context -- obviously
defeating the purpose of multithreading.

Async methods exist for us to be able to write coroutines without
multithreading. When you use multiple threads, you don't need async at
all.

I disagree. Async is a nice way to use the reactor pattern without
having to specify callbacks, hence the control flow is easier to grasp
-- and indeed it solves many people for which traditionally software
engineers think they need threads. However obviously the reactor pattern
and coroutines are not always an alternative to using threads, as they
don't provide parallelism.

Anyways, my original question was a technical one, not whether it's good
architecture or not to do so (and Vala as a programming language should
not limit how users want to use it) -- hence my original question still
stands.

-- 
:M:




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