I've been reading about coroutines in the Lua 5.1 docs and had a few questions about it.
1) Is a coroutine related to multithreading or spawning a separate process? In other words, does it enable the use of multiple cores to allow the main process to happen on one core, and another process to happen in parallel, on a different core?
2) Do you recommend using them routinely instead of state variables? Pause a script with yield and resume it later when a condition is met, rather than repeatedly using an if statement to check the value of a variable (and wasting processor time as a result)?
3) What else are coroutines commonly used for, or are they a niche feature of the language?
1) Is a coroutine related to multithreading or spawning a separate process? In other words, does it enable the use of multiple cores to allow the main process to happen on one core, and another process to happen in parallel, on a different core?
2) Do you recommend using them routinely instead of state variables? Pause a script with yield and resume it later when a condition is met, rather than repeatedly using an if statement to check the value of a variable (and wasting processor time as a result)?
3) What else are coroutines commonly used for, or are they a niche feature of the language?