coroutine.wrap
Creates a thread and returns a function to resume it
Prototype
f = coroutine.wrap (f)
Description
Creates a thread with body f, and then returns a function that can be used to resume the thread. This is a slightly simpler interface than the coroutine.create / coroutine.resume sequence, however it makes error management harder.
function f (s)
print ("Entering f with value", s)
v = coroutine.yield ()
print ("After yield, v is", v)
return 22
end -- f
resumer = coroutine.wrap (f)
resumer (88) -- start thread
resumer (99) -- resume after yield
-->
Entering f with value 88
After yield, v is 99
Lua functions
- coroutine.create - Creates a new coroutine thread
- coroutine.resume - Start or resume a thread
- coroutine.running - Returns the running coroutine
- coroutine.status - Returns the status of a thread
- coroutine.yield - Yields execution of thread back to the caller
Topics
- Lua PCRE regular expression functions
- Lua base functions
- Lua bc (big number) functions
- Lua bit manipulation functions
- Lua coroutine functions
- Lua debug functions
- Lua io functions
- Lua math functions
- Lua os functions
- Lua package functions
- Lua script extensions
- Lua string functions
- Lua syntax
- Lua table functions
- Lua utilities
- Scripting callbacks - plugins
- Scripting