Questions tagged [lua-lanes]

Lua Lanes is a Lua extension library providing the possibility to run multiple Lua states in parallel.

Lua Lanes is one of several multithreading libraries for the Lua scripting language. It allows creation of OS threads and passing Lua functions and data between these. Locking is automatic so writing of multithreaded code should be relatively easy.

Use this tag for questions explicitly referring to Lanes. For general questions on Lua multithreading, use tags s.a. and (maybe along with ).

Lanes is included into your software by the regular require "lanes" method. No C side programming is needed; all APIs are Lua side, and most existing extension modules should work seamlessly together with the multiple lanes. It can be ownloaded from its official git-page.

Lua Lanes features:

  • Lanes have separated data, by default. Shared data is possible with Linda objects.
  • Communications is separate of threads, using Linda objects.
  • Data passing uses fast inter-state copies (no serialization required)
  • "Deep userdata" concept, for sharing userdata over multiple lanes

Limitations:

  • coroutines are not passed between states
  • sharing full userdata between states needs special C side preparations (-> deep userdata)
  • network level parallelism not included
19 questions
7
votes
2 answers

LuaLanes and LuaSockets

I'm working on a little Lua app (under Lua for Windows, if that matters) that uses sockets to communicate with the outside world. (LuaSocket) And I'm trying to make several requests in parallel. So I thought LuaLanes was the way to go. (I'm open to…
Cyclonus
  • 507
  • 5
  • 13
3
votes
1 answer

LuaLanes Unable to pass global variables between functions (in a single lane)

hope you're having a good day. I have been programming a IRC chatbot in Lua the past few days, and finally I want to start implementing multiple server support into it. So far, I have created the irc "object" to manage each server, and all that…
FurryHead
  • 1,479
  • 3
  • 16
  • 19
3
votes
2 answers

lua-lanes in luajit2

Is there a way to use lanes library inside luajit 2 ? As far as I got, there is a limitation in luajit that lua_dump() c-api function is not supported. Is there some other way to get code chunk of given function ?
Alex
  • 2,837
  • 5
  • 25
  • 27
3
votes
0 answers

Lua Lanes: using a C library

We are running an c library that is tested trough a Lua testscript. This runs fine, but we decided that it was time for some multithreading. So we started implementing Lua Lanes but got stuck on loading the C lib for the threads. So we have a…
Cheiron
  • 3,620
  • 4
  • 32
  • 63
3
votes
0 answers

Lua Lanes crashes application

I have a Lua script which useslatest lua lanes. I have following script made for local lanes = require "lanes" lanes.configure() require "helper_interfaces" --require "assert" local cleanup local error_func = function(err) …
2
votes
2 answers

Lua Lanes and multi-core support: Can it be done?

Lua Lanes says that it enables multi-core support through multithreading. Isn't this incorrect? Don't you need to use multiple processes to take advantage of multiple cores? Does Lua Lanes do this? Perhaps I'm misinterpreting what they're saying.…
mattbasta
  • 13,492
  • 9
  • 47
  • 68
2
votes
0 answers

passing package.path variable to lua lanes

I wanted to pass package.path to lua lanes Code Snippet below :- package.path = package.path..";..\\Test\\?.lua" local function lane1() .. end Thread1= lanes.gen("*",{globals = _G},lane1) T1 = Thread1() T2 = Thread2() T1:join() Is it…
Anoop
  • 137
  • 1
  • 7
1
vote
2 answers

Call c function from Lua-lanes

I want to call c function from lua using lanes. int initApp(lua_State *L) { lua_createtable(L, 0, 0); lua_pushcfunction(L, get_appinfo); lua_setfield(L, -2, "get_appinfo"); lua_setglobal(L, "App"); return…
vvkatwss vvkatwss
  • 3,345
  • 1
  • 21
  • 24
1
vote
1 answer

How to convert a luajit pointer to a string and back?

I need some help converting a luajit pointer to a string and back. First I define the ctype: ffi.cdef[[ typedef struct { unsigned char Bytes[16]; } EncryptionKeys[100000000]; void* malloc(size_t); void…
1
vote
2 answers

How to detect and quick a lua function taking too long to respond?

I'm using Corona SDK to make a simple app that requires luasocket. Corona SDK support luasocket to do async http req. But I want to use UDP from luasocket. UDP receive() method from luasocket is blocking until it receives a message. Corona SDK…
astk
  • 225
  • 2
  • 7
1
vote
2 answers

Sharing a global variable between Lua lanes

I wanted to share a global variable between 2 lanes,the idea is that when lane1 updates a shared variable,i should be able to get it's updated value on lane2 when it gets scheduled. Is there a solution to this? Code Snippet below :- shared_variable…
Anoop
  • 137
  • 1
  • 7
1
vote
2 answers

Unable to call a C function from Lua-lanes

While trying to call a C function from Lua module, using Lua-lanes, the control doesn't transfer to the 'C' function. Is there any problem with which Lua-lanes won't work in a threaded way with an external C dll? Below is the code snippet Lua…
Anoop
  • 137
  • 1
  • 7
1
vote
1 answer

How do I get Lua Lanes to work with my game server?

I've been racking my brain at this all day and I just cannot figure it out. My server uses a single state that loads all of my scripts in as global variables (for calling any time without having to luaL_dofile each time I want to run a script). The…
0
votes
0 answers

Use {globals = _G}, return lanes.lua:329: can't copy non-deep full userdata across lanes

Most solutions here use lanes.gen("*",{globals = _G},func). When I run it, I get can't copy non-deep full userdata across lanes. Maybe this is because of io.stderr, io.stdout, io.stdin which are file type or lanes.core.cancel_error which is userdata…
vvkatwss vvkatwss
  • 3,345
  • 1
  • 21
  • 24
0
votes
0 answers

Lua socket.dns.toip wont work in lane thread worker

I am trying to create multithreaded watcher, which try to check hostname. The simple code demonstrate general idea. But i got strange behavior of script when i call sock.dns.toip in thread worker. Worker do not executed. If i exclude socket code…
1
2