Re: [Vala] Further speculations on couroutines, generators and threads : Emulating Go's goroutines and channels in Vala



Jim Peters wrote:
Threads are allocated on multiple cores nowadays and you can use
lock-free data structures when possible. Still you didn't provide
any benchmark, only thoughts.

We are both putting forward "only thoughts".

To prove my point I will have to implement simple coroutines in Vala
using low-level C stuff, i.e. setcontext/makecontext/etc.  I guess a
Coroutine class could be useful for something someday.  Give me a
moment ...

Actually, even though Serge was starting off two threads in his
example, and the GIO docs claim that async stuff uses GThread, the
async code from Generator doesn't use them.  It all runs in a single
thread.  I just traced through the loop with GDB and checked the GLib
source.

So everything I said about the cost of kernel context switches doesn't
apply.  Also the stuff you said about multiple cores and lock-free
data structures doesn't apply either.

So things aren't as they seemed.  Sorry for the distraction.

Incidentally, the rules for use of async functions aren't that clear.
In your Generator you're calling an async function 'helper()' from a
non-async function 'new Generator()'.  Reading the C, I can kind of
see how it is working.  Is there any good web page on the theory of
async stuff, either in Vala or C?

Jim

-- 
 Jim Peters                  (_)/=\~/_(_)                 jim uazu net
                          (_)  /=\  ~/_  (_)
 UazĂș                  (_)    /=\    ~/_    (_)                http://
 in Peru            (_) ____ /=\ ____ ~/_ ____ (_)            uazu.net



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