English [Lua 5.1] Lua Lanes (Shared global environment) icon

8 comments
18.02.14 04:44:19 pm
like 4 like it!
1.69 mb, 67 Downloads
Starkkz
Moderator
Offline Off
What is Lua Lanes?
Lua Lanes is a multithreading module for Lua 5.1 and Lua 5.2. Just like coroutines, but the best of it is that it does NOT freeze.

What is multithreading?
http://whatis.techtarget.com/definition/multithreading

Here you see I've made a modified version of Lua Lanes that allows you to use the same function environment as the main Lua state, all the memory is shared between CS2D's Lua state and this Lua state. Here's an example of code.

Code:
1
2
3
4
5
6
7
a = 32
function printa()
     print( a )
end

StartThread = lanes.gen("*", printa)
StartThread()


Frequently Asked Questions >


NOTES >


IMPORTANT ADVISE: Memory accessing/writing must be managed with mutexes, using this module always exposes your server to a crash.

I've uploaded this file under this copyright
https://github.com/LuaLanes/lanes/blob/master/COPYRIGHT
edited 15×, last 07.08.16 06:59:08 pm
x This file has been reviewed and declined by Fraizeraust (09.05.17 05:00:12 pm)
As requested by user Starkkz.

Comments

8 comments
Goto Page
To the start Previous 1 Next To the start

Log in!

You need to log in to be able to write comments!Log in
09.05.17 04:58:12 pm
Up
Starkkz
Moderator
Offline Off
Someone please reject this file, it's not thread safe.
05.08.14 10:36:34 pm
like I like it!
Up
TrialAndError
User
Offline Off
Yes, finally, I found it, Thank you @user Starkkz:
21.02.14 07:08:52 am
like I like it!
Up
MikuAuahDark
User
Offline Off
Before using: call lanes.configure first(without any parameter)
Code:
1
2
3
lanes=dofile'lanes.lua'
lanes.configure()
-- Your code here


(Hint for newbies)
20.02.14 09:04:36 pm
like I like it!
Up
_Yank
User
Offline Off
So, you did it, Wonderful ! BTW did you get it to work under Linux ?
19.02.14 01:14:36 pm
Up
Starkkz
Moderator
Offline Off
@user MikuAuahDark: Yes, REAL multithreading.
19.02.14 11:22:29 am
like I like it!
Up
MikuAuahDark
User
Offline Off
Is this a REAL multithreading?
18.02.14 10:04:19 pm
Up
Starkkz
Moderator
Offline Off
@user VADemon: I meant when the main lua state is closed, the generated lua threads (coroutines) will remain in the OS threads that are running. I made a timer in a separate thread to test this and it resulted into a crash of the application (On CS2D, when I changed the map, the server's Lua state died but the threads were still alive thus the timer in them tried to access the dead Lua state).
18.02.14 08:39:03 pm
like I like it!
Up
VADemon
User
Offline Off
http://kotisivu.dnainternet.net/askok/bin/lanes/

user Starkkz has written:
(The thread is not automatically closed unless the program itself it's closed).

Reuse opened threads?
To the start Previous 1 Next To the start