mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-16 13:59:55 +02:00
Manual is almost done. HTTP is missing.
Implemented new distribution scheme. Select is now purely C. HTTP reimplemented seems faster dunno why. LTN12 functions that coroutines fail gracefully.
This commit is contained in:
@ -8,9 +8,8 @@
|
||||
-----------------------------------------------------------------------------
|
||||
-- Setup namespace
|
||||
-----------------------------------------------------------------------------
|
||||
local ltn12 = {}
|
||||
setmetatable(ltn12, { __index = _G })
|
||||
setfenv(1, ltn12)
|
||||
_LOADED["ltn12"] = getfenv(1)
|
||||
|
||||
filter = {}
|
||||
source = {}
|
||||
sink = {}
|
||||
@ -19,10 +18,6 @@ pump = {}
|
||||
-- 2048 seems to be better in windows...
|
||||
BLOCKSIZE = 2048
|
||||
|
||||
local function shift(a, b, c)
|
||||
return b, c
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Filter stuff
|
||||
-----------------------------------------------------------------------------
|
||||
@ -53,7 +48,9 @@ local function chain2(f1, f2)
|
||||
end
|
||||
end)
|
||||
return function(chunk)
|
||||
return shift(coroutine.resume(co, chunk))
|
||||
local ret, a, b = coroutine.resume(co, chunk)
|
||||
if ret then return a, b
|
||||
else return nil, a end
|
||||
end
|
||||
end
|
||||
|
||||
@ -149,7 +146,9 @@ function source.chain(src, f)
|
||||
end
|
||||
end)
|
||||
return function()
|
||||
return shift(coroutine.resume(co))
|
||||
local ret, a, b = coroutine.resume(co)
|
||||
if ret then return a, b
|
||||
else return nil, a end
|
||||
end
|
||||
end
|
||||
|
||||
@ -166,7 +165,9 @@ function source.cat(...)
|
||||
end
|
||||
end)
|
||||
return function()
|
||||
return shift(coroutine.resume(co))
|
||||
local ret, a, b = coroutine.resume(co)
|
||||
if ret then return a, b
|
||||
else return nil, a end
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user