[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: The differences between lua coroutine and golang goroutine?
- From: Mateusz Czaplinski <czapkofan@...>
- Date: Thu, 24 Mar 2011 10:21:59 +0100
At a risk of repeating what previous posters wrote (I'm sorry, it's
too early in the morning for me to understand "less 'no
non-preemptive' guarantees" :P), from what I know:
goroutines are partially similar to coroutines, especially in that
they tend to veer on the "cooperative" side of the fence (e.g. an
empty loop is uncooperative); however, they can be executed in
parallel over a pool of threads (where the count of threads is
~implementation-defined, but see also GOMAXPROCS). And it's true that
"there are some clear points of control transfer" (although
personally, I didn't yet care enough to investigate if they are really
so clearly defined in the spec) - meaning that at these points a
goroutine can be paused and some other one chosen to execute on a
Hope this helps should you still have some doubts.
Regarding channels, I'm not sure what would you like to know. I think
their basic ideas are already described pretty extensively on
golang.org in all the tutorials and faqs.
On Thu, Mar 24, 2011 at 4:05 AM, Dimiter "malkia" Stanev
> Hi Tang,
> From http://golang.org/doc/effective_go.html#goroutines
> "A goroutine has a simple model: it is a function executing in parallel with
> other goroutines in the same address space"
> lua coroutines are not executed in parallel, but cooperative (hence the co-
> My understanding is that go communicates through explicit channels, lua
> through implicit yield, but this is probably not entirely correct. I myself
> am go and lua newbie.
> Dimiter "malkia" Stanev
> On 3/23/2011 7:50 PM, Tang Daogang wrote:
>> Dear all,
>> Recently I am reading some introductions on go language, find that it
>> has a new concept: goroutine.
>> Anybody knows the differences between lua coroutine and golang
>> goroutine, and further 'channel'?
>> Nothing is impossible.