LuaLanes / lanes

Lanes is a lightweight, native, lazy evaluating multithreading library for Lua 5.1 to 5.4.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use deep_test.c?

TT-SW opened this issue · comments

commented

Dear friends:
I wanna use clonable_lanesclone() function in deep_test.c in my lua file, like deeptest.lua line 5

local dt = lanes.require "deep_test"

It's report error that can't find the deep_test.so file

I tried to add deep_test.c into /src/makefile to make install into core.so ,but there is so many error that I have to quit this way.

What should I do? thanks :)

commented

After one afternoon's research, I found that deep_test function is not applicable to version 5.1, sad :(

Deep-test is just a sample that demonstrates how you can implement a deep userdata. It's not supposed to be used as-is. It implements a module "deep_test". The module can be used to create deep userdata with the 2 mechanisms proposed by Lanes.

The first one is a bit like a ref-counting smart pointer implemented over a full userdata, but has the drawback of having to use a part of the Lanes source code for its implementation (luaG_newdeepuserdata).

The second one demonstrates another way, where you just have to implement a __lanesclone metamethod, and it will work just fine even in a non-Lanes environment.

And yes, it happens that I wrote this sample with specific lua 5.4 API to test multiple-uservalued userdata cloning. It could be adapted easily for lua5.1 I believe.