[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Read only objects
- From: Asko Kauppi <askok@...>
- Date: Sun, 13 Apr 2008 20:04:17 +0300
It may be doable, but it won't be easy. And you'll most likely need
to become very familiar with Lua internals.
Lua Lanes offers some of the concepts you are striving for, but it
uses stack-to-stack copying and sometimes serialization to get the job
I'd suggest taking some existing multithreading platform, s.a. Lanes,
as a starting point and modifying it to your needs. Or maybe it will
be good enough as it is?
I do need to brush up my websites ASAP. Lanes is downloadable in
LuaForge, but it's manual link is currently broken. Manual is included
in the source package, though.
Mildred kirjoitti 12.4.2008 kello 21:37:
I'm thinking about how it could be possible to get Lua working in a
preemptive multithreaded environment. And I was thinking about a way
this could be done without sharing writable memory.
Well, the idea isn't new, it comes from the COP model that can be
on the Lisaac language documentation <http://home.gna.org/isaac/>
(but not yet implemented).
So the idea is to be able to have multiple threads running
concurrently. Those threads won't be able to have shared writable
objects. If they share an object, this object must be read-only. Thus
it solves the problem when multiple threads are modifying the same
object at the same moment.
The idea continues to allow threads to call functions on other
These function call are stored in a fifo queue and executed when
possible. If a function call requires a result, the call is blocking.
Otherwise it's not blocking. And of course, all arguments to these
function call are transformed into immutable objects (read-only)
the call. This should be recursive (table members, environment,
So I was wondering how it could be done in Lua. Actually, I don't have
any knowledge about Lua internals, that's why I'm asking you.
I think that the only thing that is needed to implement this
cooperative model is the ability to:
- make an object immutable
- be able to copy (or perhaps make a reference) immutable objects from
one lua universe to another, without creating side effects that would
cause problems when the two lua universes are used concurrently (that
should be possible if the objects are immutable)
Do you think it's possible ? Easy to do ?
I know that it is possible to serialize objects ... But somehow I
think that's the right solution. And I don't think you can serialize
everything (how do you serialize functions and their upvalues ?)
XMPP: <firstname.lastname@example.org> (GoogleTalk, Jabber)
GPG: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]