[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: embedded lua in web based REPL
- From: Jonathan Castello <twisolar@...>
- Date: Sat, 20 Mar 2010 12:38:24 -0700
On Sat, Mar 20, 2010 at 12:25 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> I meant calling yield from the "real" hook, in C.
>
> -- Roberto
I'm not following. You're saying I can't use coroutine.yield() from a
Lua hook function, but I can use its equivalent from a C hook
function?
Well, okay. I think it would be really useful to be able to do it with
straight Lua, though. I've been thinking about it a lot lately; you
could almost build preemptive threads on top of it, just by having a
coroutine's hook check whatever constraints and yield when it's time
to let another thread do some work.
The specific situation I would want to use it for is in a web
application, where users can write plugins in Lua and run them on the
server, in a highly sandboxed environment. Such an approach to
coroutines would make it easy to prevent one rogue plugin from lagging
or DoSing everyone else, as the original email in this thread
mentioned. And it's important to my design that the plugins run in the
same Lua interpreter, so I don't think I could use OS-level threads
for this.
~Jonathan