A safe API for interacting with the world from web threads
#5
(05-02-2015, 03:52 AM)xoft Wrote: Sounds interesting, but I remember reading something about coroutines not being yieldable from within the C API; I might remember wrong, though.

I checked that they are before creating this thread

(05-02-2015, 03:52 AM)xoft Wrote: Also, if you coroutine.yield, you'l need to coroutine.resume at some point, who's gonna do that?

The point of this proposal is that the web thread is sitting in a loop going
release plugin lock,
yield OS thread,
aquire plugin lock,
coroutine resume


(05-02-2015, 03:52 AM)xoft Wrote: I was considering doing asynchronous web requests instead - a webadmin request would create a class object representing it (together with the response) that would be passed to Lua plugins; plugins could service the request immediately or postpone it, storing the object for later (perhaps doing a QueueTask() etc. ) and fulfill the rest of the request later on. This would be perfect for the Gallery previews - they generate asynchronously so right now when the area is previewed for the first time, there is no image to send and a dummy must be sent instead.

This is an alternative. The problem is, how do you deal with the latency of moving over to the tick thread? That's a ~50ms latency penalty. The advantage of my proposal is that in the normal case, we have no penalty compared to a query from anywhere else in the server, its just acquiring a lock. Only in the case of an actual lock conflict does the web thread backoff and let the rest of the server get on with the code.
Reply
Thanks given by:


Messages In This Thread
RE: A safe API for interacting with the world from web threads - by worktycho - 05-02-2015, 04:10 AM



Users browsing this thread: 3 Guest(s)