🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

lua_newthread

Started by
-1 comments, last by Snatch 20 years, 3 months ago
I am creating integrating lua in my game and i have some problems with lua_newthread, i have a "main" lua_state which contains table that represent object in game. Each time i run a script, i create a new thread using lua_thread, create a new thread (using SDL_CreateThread(...)) and run my script. The problems is: i created 2 scripts: The first one is : ------------------ local i i = 0 while (i < 100) do a.setMember(a.getMember()+10) end The second one is : ------------------- local i i = 0 while (i < 100) do a.setMember(a.getMember()+10) end a.setMember and a.getMember are calling C functions with the help of C closure and which should be safe thread with the use of Mutex. But at end the value of a.getMember is totaly unexpectable some times i get 10, some times -100 and other time 40 !!! It seemes to be totaly hazardous.

This topic is closed to new replies.

Advertisement