xopxe / lumen

Lua Multitasking Environment.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mutex issue

wieczorek1990 opened this issue · comments

I tried to run the mutex example (on Windows) and got:

Exception in thread "main" com.naef.jnlua.LuaRuntimeException: ...skie\1 Semestr\PG\workspace\Test\src\Lumen\mutex.lua:70: attempt to index local 'mutexd' (a nil value)
    at com.naef.jnlua.LuaState.lua_pcall(Native Method)
    at com.naef.jnlua.LuaState.call(LuaState.java:555)
    at org.eclipse.koneki.ldt.support.lua51.internal.interpreter.JNLua51Launcher.run(JNLua51Launcher.java:122)
    at org.eclipse.koneki.ldt.support.lua51.internal.interpreter.JNLua51Launcher.main(JNLua51Launcher.java:137)

I can't see where this can come from... I suppose there is a "mutex.acquire()" somewhere, instead of "mutex.acquire(mutexd)" or "mutexd:acquire()", but I can't find it.
By the way, there is an incorrect use example in the doc, fixed it.

Anyway, there is another problem: for this to work under windows you have to add a "require 'tasks/selector'.init()" at the beggining (assuming you have luasocket installed). This is needed to provide Lumen a proper method for idling. Conversely, you can change sched.idle() function to something that works under windows (it calls Linux's "sleep" command by default, don't know the windows equivalent)

FYI: Issue #7 addresses this and will automatically use the "windows" method for sleeping. Unbelievably, it's ping with the correct timout set. :)

Oh, I would've never expected THAT!