|
From: miguel s. <mig...@gm...> - 2008-08-28 23:10:54
|
Lars Hellström wrote: > Alexandre Ferrieux skrev: >>> Also, from time to time people hint at the fact that passing a >>> continuation or coroutine across the thread/interp boundary would be >>> Overly Cool, but again I'd like a few examples of what real problems >>> this would solve. > > I have no idea why that should be cool -- Miguel had however mentioned > it as something the NRE [coroutine]s cannot do, so I thought it worth > pointing out that you get it for free with [suspend]/[resume]. Maybe he > can elaborate on the usefulness of this however. Scenario: webserver on a multicore cpu, one-coroutine-per-session. Ie, maintain session state in the coro's local vars (as opposed to hitting a database or something equivalent). The way it is today, you may run as many threads as you have cores (or a bit more), and allocate user sessions to the threads on creation in order to balance the load. But once created, a session has to be resumed in the same thread each time a new request comes in. If the coros could be resumed in any thread, you could balance your load dynamically - each time a request comes in. |