lua-users home
lua-l archive

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


All is awesome in lualand. I'm having more fun as the days go by (ok, so i'm a geek!).

I've got a model where i have lots of scripts running in "parallel" (using co-routines), manually scheduled by me, either using cooperative or preemptive "multitasking" (using hooks).

Now I want to add another level of complexity.

The main code that is run within these co-routines, is run using a call to lua_resume, and then when the script decides that it needs to wait (for some event or message) (cooperative), or the scheduler decides it's had enough CPU (preemptive), it comes out of the lua_resume with a lua_yield.

My question is, once it has been yielded, can I call something else in that co-routine? Specifically, can I then call (just an example):

int result = lua_resume( L, 0 );
if (result == LUA_YIELD) {
   getMethodWithinState( L, "processMessage" );
   lua_pcall( L, 0, 0, );
}

Can I do this, or do I have to wait for lua_resume() to come back with a return code of 0 in order to execute anything else in that co-routine?

Thanks heaps!

--
// David Morris-Oliveros
// Camera & Lua Coder
// Team Bondi


------------------------------------------------------------------------
Contact:
Team Bondi Pty Ltd
Level 2, 608 Harris Street
Ultimo, NSW 2007
Australia
Tel: +61 (0)2 8218 1500
Fax: +61 (0)2 8218 1507
Web: http://www.teambondi.com
------------------------------------------------------------------------
This email may contain confidential information.  If you are not
the intended recipient, you may not copy or deliver this message to
anyone. In such case, you should destroy this message and kindly
notify the sender by reply email. Opinions, conclusions and other
information in this message that do not relate to the official business
of our firm shall be understood as neither given nor endorsed by it.
------------------------------------------------------------------------