Coco is a small extension to get True C Coroutine semantics for Lua 5.1.
Coco is both available as a stand-alone release and integrated into LuaJIT.
The stand-alone release is a patchset against the standard Lua 5.1.3 distribution. There are no dependencies on LuaJIT. However LuaJIT depends on Coco to allow yielding for JIT compiled functions.
这个luacoco patch也是匠心独特 以最小的侵入修改让lua支持原生的coroutine,解除了原版的coroutine的几个限制:
* Yield across all metamethods (not advised for __gc).
* Yield across iterator functions (for x in func do).
* Yield across callbacks (table.foreach(), dofile(), ...).
* Yield across protected callbacks (pcall(), xpcall(), ...).
* Yield from C functions and resume back to them.
在实现方面主要是利用以下几个macro来实现修改的:
/*
@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
@* (the data goes just *before* the lua_State pointer).
** CHANGE (define) this if you really need that. This value must be
** a multiple of the maximum alignment required for your machine.
*/
#define LUAI_EXTRASPACE 0
/*
@@ luai_userstate* allow user-specific actions on threads.
** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
** extra when a thread is created/deleted/resumed/yielded.
*/
#define luai_userstateopen(L) ((void)L)
#define luai_userstateclose(L) ((void)L)
#define luai_userstatethread(L,L1) ((void)L)
#define luai_userstatefree(L) ((void)L)
#define luai_userstateresume(L,n) ((void)L)
#define luai_userstateyield(L,n) ((void)L)
再拜下萝卜神!!!
分享到:
相关推荐
test for lua coroutine and linux makecontext
Lua Coroutine,协程详解,lua 基本础,The Programming Language Lua
The concept of a coroutine is one of the oldest proposals for a general control abstraction. It is attributed to Conway [Conway, 1963], who described coroutines as “subroutines who act as the master ...
今天小编就为大家分享一篇关于Lua协同程序coroutine的简介及优缺点,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
openresty和lua多功能模板
Node-Lua在下个版本将会提供以下新功能和特性: udp接口支持;tcp和udp socket在lua服务之间的迁移;在线服务热更新;在线服务调试;提供FreeBSD等环境下的编译和安装;提供基准测试版本;欢迎大家发现Node-Lua当中...
所有版本LUA源码 lua-5.3.5 lua-5.3.4 lua-5.3.3 lua-5.3.2 lua-5.3.1 lua-5.3.0 lua-5.2.4 lua-5.2.3 lua-5.2.2 lua-5.2.1 lua-5.2.0 lua-5.1.5 lua-5.1.4 lua-5.1.3 lua-5.1.2 lua-5.1.1 lua-5.1 lua-5.0.3 lua-...
argparse, 用于Lua的功能丰富的命令行 解析器 argparse Argparse是一个特性丰富的命令行 解析器,用于由Argparse启发 python 。Argparse支持位置参数,选项,标志,可选参数,子命令和更多。 Argparse自动生成用法,...
lua5.3(32位/64位)windows 预编译(exe/DLL) adding: lua5.3.5-x86/lua.exe (in=14336) (out=7311) (deflated 49%) adding: lua5.3.5-x86/lua.o (in=24873) (out=9654) (deflated 61%) adding: lua5.3.5-x86/lua...
lua 反编译工具 用于学习lua 反编汇 游戏lua 解密
ios版本将lua加密成luac
将Lua功能分配给快捷键 注册事件的回调函数 完整的Lua 5.3功能 具有自动完成功能的交互式控制台 不需要特殊权限 入门 使用Notepad ++ Plugin Admin安装插件,或者您可以从页面手动下载插件,然后将zip解压缩到...
内含luaDll,luacom以及luaiconv源码。luaDll和luaiconv直接打开sln在Visual studio中即可进行编译。luacom可使用nmake进行编译。也可直接使用已经生成了的dll.
lua for windows其实是一整套Lua的开发环境.Lua for Windows 为 Windows 系统下提供了 Lua 脚本语言的开发和运行环境。Lua 是一个小巧的脚本语言。作者是巴西人。该语言的设计目的是为了嵌入应用程序中,从而为应用...
LUAC 脚本加密 , 用于LUAC 脚本反编译,有用得同学可以下载,
这是编译好的dll(带demo),cURL比luacurl功能强大的多,项目源码及使用: https://github.com/Lua-cURL/Lua-cURLv3
在stm32f407开发板上移植lua脚本,实现一些基本功能
LUA虚拟机,提供对LUA代码进行编译/解释执行的功能。LUA类库常量(常量)。LUA类库常量掩码,提供给 LUA.加载类库() 使用.LUA类型 (常量)。LUA数据类型值。用以判断LUA传递到应用程序环境中的数据类型的一组常量。...
自己从C代码中扒出一点,只能用一点点功能。抛砖引玉吧。大师们发个全一点的代码吧。邮箱:shb_a@126.com 文件目录: lua53.dll LUA自带的 lualib.dll 自测试用的,仅有三个函数:lua_sleep-延时,showm-返回文本,...