lua-users home
lua-l archive

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



On 29/03/2013 8:38 PM, Leo Romanoff wrote:
-spc (I slowly coming to the idea that pre-emptive multitasking
is no longer a Good Thing(TM) but I still need to formulate my
thoughts on  this)

In principle, I agree with this. But I'm also not sure that explicit
cooperative multi-tasking is such a good thing.

I would go further and suggest to get rid of:

(1) any attempt to simulate sequential threads of control (ie coroutines) is gilding the lily. better to use a model that makes continuations explicit.

(2) coupling communication with cooperation, as in CSP with blocking queue/rendezvous primitives, or having nested event handlers in Erlang actions etc.

Of course the CSP religion is a force to be reckoned with.


I think that
cooperative implicit multi-tasking (with ability to control at the
meta-level or higher-level how cooperation happens, e.g. by means of
custom policies or something like this) is more bullet-proof.

My (completely idiosyncratic) view is that actors with atomic run-to-completion actions are a nice model. That way thread switch only happens in the scheduler. Actors can be raw handers or state machines (FSMs, HFSMs) and communicate (only) via non-blocking queues. Miro Samek has a nice practical book on this.

The main problem in implementing this in Lua would be supporting long running computation, (if you need to). Plus you need fully async i/o, but that's not so hard to get these days (eg luvit)

But you want to allow 3rd party code to do stupid stuff and still work. A bitter pill for any purist methodology :)

Ross