implication of nesting coroutines

Michael Fung mike at 3open.org
Sat Jul 6 07:35:03 CEST 2013


That's GOOD news for me! Thanks again Marc!

Rgds,
Michael

On 7/6/2013 1:27 PM, Marc Lehmann wrote:
> On Sat, Jul 06, 2013 at 01:19:57PM +0800, Michael Fung <mike at 3open.org> wrote:
>>
>> [code]
>> async {
>>    ...
>>    db_read();
>> }
>>
>> sub db_read() {
>>    async {
>>    ...
>>   }
>> }
>> [/code]
>>
>> This is nesting I am afraid?
>
> Ah, so you mean starting a coro inside another coro - that is lexical
> nesting of async calls indeed, but the threads themselves are not nested
> in any meaningful way: threads have their own life and execution, so
> while you can start a thread from within another thread, they don't have
> any parent-child relationship, but are indeendent of each other - either
> thread can finish before the other, and they can run interleaved as well.
>
> Or in other words, this is completely harmless (and normal programming,
> and in fact the whole point of having threads in the first place).
>



More information about the anyevent mailing list