http.lua里的装饰器
2024-10-14 19:58:34
摘自:http.lua
local co_yield = coroutine.yield
local co_create = coroutine.create
local co_status = coroutine.status
local co_resume = coroutine.resume
local select = select -- Reimplemented coroutine.wrap, returning "nil, err" if the coroutine cannot
-- be resumed. This protects user code from inifite loops when doing things like
-- repeat
-- local chunk, err = res.body_reader()
-- if chunk then -- <-- This could be a string msg in the core wrap function.
-- ...
-- end
-- until not chunk
local co_wrap = function(func)
local co = co_create(func)
if not co then
return nil, "could not create coroutine"
else
return function(...)
if co_status(co) == "suspended" then
return select(2, co_resume(co, ...))
else
return nil, "can't resume a " .. co_status(co) .. " coroutine"
end
end
end
end
最新文章
- sublime_text_2 ubuntu下无法输入中文 解决方法
- ThreadPoolExecutor-线程池开发的使用
- iptables详细说明
- Gmail 账号找回办法
- poj 2240 Arbitrage
- JQuery快速入门
- 学会使用Chromium中的LOG
- IDEA中如何添加Scala插件。 我使用的IDEA版本是14
- Fedora 11中用MinGW编译Windows的Qt4程序(在Linux系统下编译Windows的程序)
- HTTP协议下保证登录密码不被获取更健壮方式
- mysql-python模块编译问题解决
- python脚本工具-2 去除扩展名后提取目录下所有文件名并保存
- Cmake 脚本对预处理器的宏定义
- scanf和gets的区别
- 《Java从入门到放弃》JavaSE入门篇:面向对象语法一(入门版)
- 2、C#基础 - Visual Studio 的版本选择和下载
- R语言︱SNA-社会关系网络 R语言实现专题(基础篇)(一)
- 企业IT管理员IE11升级指南【9】—— IE10与IE11的功能对比
- 《剑指offer》二叉搜索树的后序遍历序列
- 拯救者Y720-gtx1050-window10-配置tensorflow-gpu环境
热门文章
- Android 获取SD路径,存储空间大小的方法
- 【转】RO段、RW段和ZI段 --Image$$??$$Limit 含义(zz)
- HDU5909Tree Cutting
- 在centos7下用http搭建配置svn服务
- LinkedList(JDK1.8)源码分析
- cf 990G - GCD Counting
- win32-api: 让 static 控件中的水平横行,垂直居中。
- 第二十二节,TensorFlow中的图片分类模型库slim的使用、数据集处理
- cmd代码:查端口占用,查进程号,杀进程
- POJ 3678 Katu Puzzle (2-SAT)