Skip to content

Commit 90d4974

Browse files
committed
add coroutine copy module
1 parent 22ecb89 commit 90d4974

File tree

11 files changed

+20
-0
lines changed

11 files changed

+20
-0
lines changed

lapis-dev-1.rockspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ build = {
6363
["lapis.cmd.templates.tupfile"] = "lapis/cmd/templates/tupfile.lua",
6464
["lapis.cmd.util"] = "lapis/cmd/util.lua",
6565
["lapis.config"] = "lapis/config.lua",
66+
["lapis.coroutine"] = "lapis/coroutine.lua",
6667
["lapis.cqueues"] = "lapis/cqueues.lua",
6768
["lapis.csrf"] = "lapis/csrf.lua",
6869
["lapis.db"] = "lapis/db.lua",

lapis/application.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local logger = require("lapis.logging")
22
local lapis_config = require("lapis.config")
3+
local coroutine = require("lapis.coroutine")
34
local Router
45
Router = require("lapis.router").Router
56
local insert

lapis/application.moon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
logger = require "lapis.logging"
33
lapis_config = require "lapis.config"
44

5+
coroutine = require "lapis.coroutine"
6+
57
import Router from require "lapis.router"
68

79
import insert from table

lapis/application/route_group.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ each_route = function(obj, scan_metatable, callback)
118118
end
119119
end
120120
end
121+
local coroutine = require("lapis.coroutine")
121122
local each_route_iter
122123
each_route_iter = function(obj, scan_metatable)
123124
return coroutine.wrap(function()

lapis/application/route_group.moon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ each_route = (obj, scan_metatable=false, callback) ->
139139
if obj_mt and type(obj_mt.__index) == "table"
140140
each_route obj_mt.__index, scan_metatable, callback
141141

142+
coroutine = require "lapis.coroutine"
142143
each_route_iter = (obj, scan_metatable) ->
143144
coroutine.wrap ->
144145
each_route obj, scan_metatable, coroutine.yield

lapis/coroutine.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
local _tbl_0 = { }
2+
for k, v in pairs(coroutine) do
3+
_tbl_0[k] = v
4+
end
5+
return _tbl_0

lapis/coroutine.moon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- this is a copy of the coroutine module that lapis will use so that calling
2+
-- code can manipulate how coroutines are handled
3+
{k, v for k,v in pairs coroutine}

lapis/validate.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local insert
22
insert = table.insert
33
local unpack = unpack or table.unpack
4+
local coroutine = require("lapis.coroutine")
45
local validate_functions = {
56
exists = function(input)
67
return input and input ~= "", "%s must be provided"

lapis/validate.moon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import insert from table
66

77
unpack = unpack or table.unpack
88

9+
coroutine = require "lapis.coroutine"
10+
911
validate_functions = {
1012
exists: (input) ->
1113
input and input != "", "%s must be provided"

lapis/validate/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ local instance_of
77
instance_of = require("tableshape.moonscript").instance_of
88
local yield_error
99
yield_error = require("lapis.application").yield_error
10+
local coroutine = require("lapis.coroutine")
1011
local unpack = unpack or table.unpack
1112
local indent
1213
indent = function(str)

0 commit comments

Comments
 (0)