[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Is this a scoping issue?
- From: jdarling@...
- Date: Thu, 16 Mar 2006 10:53:32 -0700
Shouldn't you be calling yield() instead of resume(co)?
- Jeremy
"Help I suffer from the oxymoron Corporate Security."
> -------- Original Message --------
> Subject: Is this a scoping issue?
> From: Lee Smith <wink@gettcomm.com>
> Date: Thu, March 16, 2006 11:41 am
> To: lua@bazar2.conectiva.com.br
>
> I'm having some problems with a coroutine I create. Here is the order
> of things:
>
> I create a lua_State and load 3 files into it, each containing its own
> function as follows:
>
> In file1:
>
> function init()
> print "init"
> co = coroutine.create(process)
> coroutine.resume(co)
> end
>
> In file2:
>
> function process()
> print "yielding the coroutine"
> coroutine.yield()
> print "running again"
> end
>
> In file3:
>
> function callback()
> print "resuming"
> print(coroutine.resume(co))
> end
>
>
> Now, when I make a lua_pcall to init, the coroutine starts the process
> function just like I would expect. Once it yields, I run off and do
> some stuff in my c code, and then pcall callback to wake the coroutine
> back up. However the call to resume is failing. Here is my output:
>
> init
> yielding the coroutine
> c++ - doing some work
> resuming
> false cannot resume non-suspended coroutine
>
> Any ideas as to where I've gone wrong?