Lua C API如何高效处理海量数据?

2026-04-01 20:451阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计278个文字,预计阅读时间需要2分钟。

Lua C API如何高效处理海量数据?

在代码中处理皮秒(数字+10+^+12)后,将数据传递给Lua的C代码(atime和eventid都是size_t类型):

clua_getglobal(luactx, timer_callback);lua_pushunsigned(luactx, atime);lua_pushunsigned(luactx, eventid);lua_pcall(luactx, 0, 0, 0);

Lua C API如何高效处理海量数据?

我在代码中处理皮秒(数字> 10 ^ 12).
将数据传递给Lua的C代码(atime和eventid都是size_t类型)

lua_getglobal ( luactx, "timer_callback" ); lua_pushunsigned ( luactx, atime ); lua_pushunsigned ( luactx, eventid ); lua_pcall ( luactx, 2, 0, 0 );

Lua功能

function timer_callback(time, eventid) if eventid == TX_CLOCK then out_log(tostring(time)) --result is random garbage set_callback(time + 1000000000000, TX_CLOCK) return end end

我尝试使用lua_pushnumber,但结果是lua我得到了负数.

Lua,从5.3开始,支持lua_Integer,默认为64位.从 reference manual:

lua_Integer

typedef … lua_Integer;

The type of integers in Lua.

By default this type is long long (usually a 64-bit two-complement integer), but that can be changed to long or int, usually a 32-bit two-complement integer. (See LUA_INT in luaconf.h.)
Lua also defines the constants LUA_MININTEGER and LUA_MAXINTEGER, with the minimum and the maximum values that fit in this type.

通过编辑luaconf.h,可以相当容易地强制使用Lua 5.2 lua使用不同的数字类型.数字类型定义为LUA_NUMBER.

对于lua 5.1,您可以安装lnum补丁,这将更改整数类型.

本文共计278个文字,预计阅读时间需要2分钟。

Lua C API如何高效处理海量数据?

在代码中处理皮秒(数字+10+^+12)后,将数据传递给Lua的C代码(atime和eventid都是size_t类型):

clua_getglobal(luactx, timer_callback);lua_pushunsigned(luactx, atime);lua_pushunsigned(luactx, eventid);lua_pcall(luactx, 0, 0, 0);

Lua C API如何高效处理海量数据?

我在代码中处理皮秒(数字> 10 ^ 12).
将数据传递给Lua的C代码(atime和eventid都是size_t类型)

lua_getglobal ( luactx, "timer_callback" ); lua_pushunsigned ( luactx, atime ); lua_pushunsigned ( luactx, eventid ); lua_pcall ( luactx, 2, 0, 0 );

Lua功能

function timer_callback(time, eventid) if eventid == TX_CLOCK then out_log(tostring(time)) --result is random garbage set_callback(time + 1000000000000, TX_CLOCK) return end end

我尝试使用lua_pushnumber,但结果是lua我得到了负数.

Lua,从5.3开始,支持lua_Integer,默认为64位.从 reference manual:

lua_Integer

typedef … lua_Integer;

The type of integers in Lua.

By default this type is long long (usually a 64-bit two-complement integer), but that can be changed to long or int, usually a 32-bit two-complement integer. (See LUA_INT in luaconf.h.)
Lua also defines the constants LUA_MININTEGER and LUA_MAXINTEGER, with the minimum and the maximum values that fit in this type.

通过编辑luaconf.h,可以相当容易地强制使用Lua 5.2 lua使用不同的数字类型.数字类型定义为LUA_NUMBER.

对于lua 5.1,您可以安装lnum补丁,这将更改整数类型.