Skip to content

LuaRef and lua threads (coroutines) #112

@Mellnik

Description

@Mellnik

I am using LuaRef to save values from Lua that will be later restored to Lua on request. This can happen from inside a coroutine.

When calling LuaRef::push the value will always be pushed to the state on which the reference was created with. The problem is that values can be saved from the main Lua thread and later be restored from another Lua thread. In this case the push will fail.

A workaround could be to always call LuaRef::moveTo before pushing the value. But that would be totally useless because the Lua registry is global and not per thread. The function is doing nonsense by calling luaL_unref on the first thread and then calling luaL_ref again on the other thread, effectively doing nothing.

Please make LuaRef::push(lua_State* L) to actually push the values on the given state and not the saved one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions