|
As you did not specified
if you wanted your users to have access to coroutines, and as it may not be obvious, you should know that you can also
prevent your users from using coroutines. This does not break anything else in
Lua, and there are multiple and easy ways to do that (for example _G.coroutine =
nil before any user script). De : lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] De la part de Lua Envoyé : 14 août 2006 14:16 À : Lua list Objet : lua_yield() equivalent? I am working on a messaging/collaborative application. We are thinking about using either _javascript_ or Lua to allow third parties to (safely =) script the client. The network model between the client and server is very asynchronous in that several requests can be outstanding in either direction. In our existing code, we handle this by having a queue of objects waiting for their reply and a function is called in each when their data arrives. For simplicity for the script users (who are less technically competent), I want the script to read something like this: MsgObj = Msg.OpenByPath("SomePath") FldData = MsgObj:GetFieldData() Note that the first line involves a round trip to the server. I am currently assuming the users will not be using coroutines and I am making the above work by lua_yield()ing back to where I called the interpreter, waiting for the open message to come back from the server, then lua_resume()ing back the message object. The problem with this is if the user uses a coroutine, the yield in Msg.OpenByPath() won't yield all the way back out. Is there some other way to break out of Lua execution all the way back to the initial call into the interpreter, leaving the state intact so I can resume it later once I have the available data? (One thing I did look at was the downloading of files example in the PiL 2nd edition, however, I don't want to expect that level of competency from our users. Also, I want control back in the C code as quickly as possible to handle other network and UI events that Lua isn't involved with.) Thanks for any insights you might be able to provide, James. P.S. Sorry for the funny from name, I'm trying to fix that. |