lua-users home
lua-l archive

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


We should just step through the sequence of events in that main_async(), to make this clear:

1. nursery is opened, and the two concurrent child tasks are queued
2. end of the nursery block is reached (after "waiting for child tasks") --> yield to the scheduler
3. scheduler starts the child tasks (arbitrary order)
4. both child tasks call async_sleep() (for 2 and 3 s, respectively), and yield to the scheduler
5. the scheduler has nothing to do for 2 seconds, so it sleeps
6. scheduler resumes the "2 s"  child, and he returns
7. scheduler has nothing to do for 1 second
8. scheduler resumes the "3 s" child, and she returns
9. scheduler resumes the task with the nursery block, and he returns