coro
Coroutine manager for SkyOS. Might work, might not, who knows.
coros | Currently running coroutines. |
---|---|
activeCoros | Currently active coroutines, with pid as key. |
newCoro(func [, name [, parent [, env [, forceActive]]]]) | Make a new coroutine and add it to the currently running list. |
killCoro(coro) | Kill a coroutine, and remove it from the coroutine table. |
runCoros() | Run the coroutines. |
stop() | Stop the coroutine manager, halting all threads after current loop. |
resume(pid, ...) | Resume a coroutine with a custom event, with error handling and such. |
- corosSource
Currently running coroutines. This is stored in
SkyOS.coro.coros
- activeCorosSource
Currently active coroutines, with pid as key.
- newCoro(func [, name [, parent [, env [, forceActive]]]])Source
Make a new coroutine and add it to the currently running list.
Parameters
- func function Function to run forever.
- name? string Name of the coroutine, defaults to
coro
. - parent? number Parent PID, mirrors it's active state.
- env? table Custom environment to use for coroutine, defaults to
_ENV
. - forceActive? boolean Whether or not this coroutine will always have user events.
Returns
- number PID of the coroutine. This shouldn't change.
- killCoro(coro)Source
Kill a coroutine, and remove it from the coroutine table.
Parameters
- coro Coroutine to kill, accepts a number (index in table) or a string (name of coroutine).
- runCoros()Source
Run the coroutines. This doesn't take any parameters nor does it return any.
- stop()Source
Stop the coroutine manager, halting all threads after current loop. Note that this will not stop it immediately.
- resume(pid, ...)Source
Resume a coroutine with a custom event, with error handling and such.
Parameters
- pid number Process ID of coroutine to resume.
- ... Event details to resume with.