Costatus
Jump to navigation
Jump to search
costatus( cor )
- Tests a coroutine and returns a string representing its status.
- cor
-
- The coroutine to test.
A coroutine is a special kind of function that can yield control back to the caller without completely exiting. The caller can then resume the coroutine as many times as needed until the function exits.
The costatus()
function takes a coroutine object and returns its status as a string value, either 'running' 'suspended' 'normal'
or 'dead'
. You can use this to test whether the most recent call to coresume()
yielded or terminated.
running | This is the coroutine that's currently running - aka the one that just called costatus. |
suspended | This coroutine is not running - either it has yielded or has never been resumed yet. |
normal | This coroutine is currently waiting in coresume for another coroutine. (Either for the running coroutine, or for another normal coroutine) |
dead | This coroutine has either returned or died due to an error. |
Technical notes
When a coroutine dies unexpectedly, this status merely goes to 'dead'
, but additional information is also available about the reason and the location. See coresume()
and trace()
for details.
Examples
See cocreate()
for an example.