[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: another yield/resume question
- From: "Thijs Schreijer" <thijs@...>
- Date: Mon, 11 Jun 2012 23:32:56 +0200
> I'm trying to learn more about the requirements of yield/resume and
> found this (http://vlists.pepperfish.net/cgi-bin/mailman/private/lua
> -l-lists.lua.org/2012-June/023709.html ) email which states
>
> Yes, L is in an invalid state, because it yielded. While it is
suspended,
> you cannot change its stack. More specifically, the thread "thinks"
> it is running a Lua function (because it was inside a Lua function
when
> it yielded), so it is not ready to accept API operations.
>
> I have the following script which is evaluated in its own thread and
> the yield* functions will yield for an unspecified amount of time
>
> function foo()
> for i = 1, 3 do
> yield1("test", i)
> end
> end
>
> function bar()
> t = { "test", "hello" }
> yield2(t)
> end
>
> yield3()
>
> While the script is yielded inside of yield3, can function foo or bar
> be called? And the same would follow for yield1 or yield2? If I can't
> enter L while it's yielded would it work if I made a new thread each time?
>
> John
The message you are referring to is related to the C side api, not to
yielding
from Lua scripts, which your examples seem to relate to.
So with 'which is evaluated in its own thread', do you mean with 'thread',
an OS thread, or a
Lua coroutine?