summaryrefslogtreecommitdiff
path: root/meta/template/coroutine.lua
blob: accd814b03250b269b1fcc0067efab932b1c5726 (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
---@meta

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

---@alias coroutine* coroutinelib

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

---#if VERSION >= 5.4 then
---#DES 'coroutine.isyieldable>5.4'
---@param co? thread
---@return boolean
function coroutine.isyieldable(co) end
---#else
---#DES 'coroutine.isyieldable'
---@return boolean
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
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'
function coroutine.status(co) end

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

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

return coroutine