lua-users home
lua-l archive

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

I think you can bypass the problem by using a lua coroutine-scheduler.

On Sun, Jan 18, 2009 at 19:49, Tobias Markmann <> wrote:

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 something like this is possible. So my question is: How to yield/resume the right way from C? 


Linker Lin