aboutsummaryrefslogtreecommitdiff
path: root/src/ltn12.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-15 06:24:00 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-15 06:24:00 +0000
commit58096449c6044b7aade5cd41cfd71c6bec1d273d (patch)
tree1814ffebe89c4c2556d84f97f66db37a7e8b4554 /src/ltn12.lua
parent9ed7f955e5fc69af9bf1794fa2c8cd227981ba24 (diff)
downloadluasocket-58096449c6044b7aade5cd41cfd71c6bec1d273d.tar.gz
luasocket-58096449c6044b7aade5cd41cfd71c6bec1d273d.tar.bz2
luasocket-58096449c6044b7aade5cd41cfd71c6bec1d273d.zip
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.
Diffstat (limited to 'src/ltn12.lua')
-rw-r--r--src/ltn12.lua21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/ltn12.lua b/src/ltn12.lua
index 41855f0..6228247 100644
--- a/src/ltn12.lua
+++ b/src/ltn12.lua
@@ -8,9 +8,8 @@
8----------------------------------------------------------------------------- 8-----------------------------------------------------------------------------
9-- Setup namespace 9-- Setup namespace
10----------------------------------------------------------------------------- 10-----------------------------------------------------------------------------
11local ltn12 = {} 11_LOADED["ltn12"] = getfenv(1)
12setmetatable(ltn12, { __index = _G }) 12
13setfenv(1, ltn12)
14filter = {} 13filter = {}
15source = {} 14source = {}
16sink = {} 15sink = {}
@@ -19,10 +18,6 @@ pump = {}
19-- 2048 seems to be better in windows... 18-- 2048 seems to be better in windows...
20BLOCKSIZE = 2048 19BLOCKSIZE = 2048
21 20
22local function shift(a, b, c)
23 return b, c
24end
25
26----------------------------------------------------------------------------- 21-----------------------------------------------------------------------------
27-- Filter stuff 22-- Filter stuff
28----------------------------------------------------------------------------- 23-----------------------------------------------------------------------------
@@ -53,7 +48,9 @@ local function chain2(f1, f2)
53 end 48 end
54 end) 49 end)
55 return function(chunk) 50 return function(chunk)
56 return shift(coroutine.resume(co, chunk)) 51 local ret, a, b = coroutine.resume(co, chunk)
52 if ret then return a, b
53 else return nil, a end
57 end 54 end
58end 55end
59 56
@@ -149,7 +146,9 @@ function source.chain(src, f)
149 end 146 end
150 end) 147 end)
151 return function() 148 return function()
152 return shift(coroutine.resume(co)) 149 local ret, a, b = coroutine.resume(co)
150 if ret then return a, b
151 else return nil, a end
153 end 152 end
154end 153end
155 154
@@ -166,7 +165,9 @@ function source.cat(...)
166 end 165 end
167 end) 166 end)
168 return function() 167 return function()
169 return shift(coroutine.resume(co)) 168 local ret, a, b = coroutine.resume(co)
169 if ret then return a, b
170 else return nil, a end
170 end 171 end
171end 172end
172 173