lua-users home
lua-l archive

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


On Tue, Mar 13, 2007 at 09:49:40AM -0300, Roberto Ierusalimschy wrote:
> > If i have to serialize all data, send it as a byte stream into another
> > interpreter and deserialize there, i can also live with serparate
> > processes. I'm not sure if you can migrate a complete object structure
> > from one interpreter instance to another in LUA (i don't believe you
> > can).
> 
> When we use threads without shared memory, frequently we have to think
> differently from the way we think with shared memory. For instance,
> instead of sending data all around (through serialized streams), it is
> common to have one process for each data (an object? an abstract data
> type?), so that what flows around are "messages" (in the OO sense) to
> manipulate that data. You never migrate a complete object structure
> from one interpreter instance to another. You simply send a process
> reference from one instance to another.

"complete object structure" is not the same as "large object structure",
its useful to send "primitive" data in messages:

  endpoint.send{
	  type = "load-config"
	  with = {
		  "arg1",
		  "arg2",
		  "arg3"
	  }
  }

-- on some other state on another OS thread/process/machine:

  msg = endpoint.recv

  if msg.type == "load-config" then
	  for v in ipairs(msg.with) do
		  loadfile(v)
	  end
  -- ...

Tables are used for everything in lua, but tables used as "arrays" or
"hash maps" are useful payload in small messages.

Sam