lua-users home
lua-l archive

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



It may be a bit early to throw this in the air (implementation at 0%) but I'd want to know if there's any glitches in the design. Throwing stones requested, in other words... ;)


Lua Lanes

I've long wanted to have seeming parallelism in Lua, something akin to DBUS-kind message passing but made to be syntactically so "sweet" it would seem native, transparent, and noncluttered in the code. Lately, I crafted a mechanism that would make such calls seem like regular function calls, using userdata as handles to the returned values.

  f= lane( ...chunk-of-lua-code... )

  a= f( ...args... )	-- starts chunk in a new thread
  b= f( ...other-args... )	-- another thread
  ...
  print( a[1] + b[1] )	-- first use of returned values

Only _using_ the values (any fields of 'a' or 'b') will actually pend on their execution to become finished. No locking at the application level is required.

What this also allows, is 'a' and 'b' to be passed further (even to other threads) as parameters, without requiring their processing to have finished, yet.

Is this the way _real_ multithreading should be introduced to Lua?  :)

-asko