lua-users home
lua-l archive

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


Diego Nehab asked:

>Is something in between enough? Perhaps a mechanism 
>allowing threads to create tables that are not accessible 
>from other threads (an error could be raised if 
>unauthorized access attempted), and a thread-safe way 
>to move such tables from one thread to the other?

That sounds great to me. You could write code in a CSP style, like you 
would with LuaTask, but the messages passed could be made very 
lightweight.

Might the author of LuaThread 1 be convinced to write LuaThread 2, and to 
include just such a feature :-)

Seems that you could start with the LuaThread 1 API, for complete backward 
compatibility, with just a few API additions.

For example, the addition of:

1. A read-only environment in which any thread can create a table, and 
then label it "visible to all." Any write access from any thread throws an 
error. The original creator of the table can atomically destroy the table, 
or can atomically switch it over to a new table and destroy the original. 
(Useful for centrally managing configuration data for other threads.)

2. A shared environment in which any table is accessible only by one 
thread. Access from any other thread throws an error. The owning thread 
can atomically transfer ownership to any other thread. (Lets you do 
the CSPs.)