lua-users home
lua-l archive

RE: PATCH: true C coroutines -- yield across C stack from anywhere

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


Hi to all,
I'm planning to use lua coroutines in my script engine, and i am wondering
if it is possible to tell lua to restart at a specific line of code when you
resume a thread.
For example i have the following function used to create a coroutine:
function Myfunction( )
	local index = 0 
	while index < 1000 do
	-- call dummy function
	DoSomething()
	-- call special C function that will yield or allow coroutine to
-- continue execution
	WaitEvent( idEvent )
	index = index + 1 	
	
	end
end
What i want to do is that when the C function WaitEvent is called, it yields
the coroutine..
That is working perfectly, but i want the coroutine to restart at the
function WaitEvent and not the line after ( index = index + 1 )...
In this way, each time i call a resume on the coroutine, the same C
function is called and decide if coroutine must yield and stay at it, or
continue it's execution..
Does anybody already made such a thing ???
Thanks in advance..
JC.
PS: sorry for my bad english.

AltStyle によって変換されたページ (->オリジナル) /