lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I'm writing an application which enables users scripts to be executed, multiple in parallel. So each script has its own lua_State. Now i want to provide those scripts a function they can call to be continued later, for example wait(60) to wait 60 seconds and then be resumed. My idea was to just yield those scripts from C and resume them after 60 seconds. That way they won't need to wait in a locking way in its own OS thread.
Though what happens when I try to execute my wait C function from Lua which is build like,

lua_yield(L, 0);
printf("After yield\n");
return 0;

  , is that i get the following error:
attempt to yield across metamethod/C-call boundary
stack traceback:
	[C]: in function 'wait'
I thought with the coro patch from luajit.org something like this is possible. So my question is: How to yield/resume the right way from C? 

Cheers,
Tobias