summaryrefslogtreecommitdiff
path: root/meta/template/coroutine.lua
blob: 0b07bf5cbda1fd56394cc0549fce5a958eeef714 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---@meta

---#DES 'coroutine'
---@class coroutinelib
coroutine = {}

---#DES 'coroutine.create'
---@param f async fun()
---@return thread
---@nodiscard
function coroutine.create(f) end

---#if VERSION >= 5.4 then
---#DES 'coroutine.isyieldable>5.4'
---@param co? thread
---@return boolean
---@nodiscard
function coroutine.isyieldable(co) end
---#else
---#DES 'coroutine.isyieldable'
---@return boolean
---@nodiscard
function coroutine.isyieldable() end
---#end

---@version >5.4
---#DES 'coroutine.close'
---@param co thread
---@return boolean noerror
---@return any errorobject
function coroutine.close(co) end

---#DES 'coroutine.resume'
---@param co    thread
---@param val1? any
---@return boolean success
---@return any result
---@return ...
function coroutine.resume(co, val1, ...) end

---#DES 'coroutine.running'
---@return thread running
---@return boolean ismain
---@nodiscard
function coroutine.running() end

---#DES 'coroutine.status'
---@param co thread
---@return
---| '"running"'   # ---#DESTAIL 'costatus.running'
---| '"suspended"' # ---#DESTAIL 'costatus.suspended'
---| '"normal"'    # ---#DESTAIL 'costatus.normal'
---| '"dead"'      # ---#DESTAIL 'costatus.dead'
---@nodiscard
function coroutine.status(co) end

---#DES 'coroutine.wrap'
---@param f async fun()
---@return fun()
---@nodiscard
function coroutine.wrap(f) end

---#DES 'coroutine.yield'
---@async
---@return ...
function coroutine.yield(...) end

return coroutine