lua-users home
lua-l archive

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


There is no pre-emptive multithreading in Lua, coroutines are cooperative and hence don't need any kind of locking.

On Sun, Apr 10, 2011 at 10:20 AM, Valerio Schiavoni <valerio.schiavoni@gmail.com> wrote:
Hello,

what is the suggested technique to implement concurrent tables?

Here, concurrent could have different meanings. 
Let's say for now that the same semantic as the ConcurrentHashMap of the Java's JDK apply.

javadoc for ConcurrentHashMap: http://bit.ly/f3MXN9

If the topic's already been discussed, please point me to that discussion.

More in general, how do you implement coroutine-safe/thread-safe data-structures ? 
Do you attach locks to the table's metatable ?

Pointers to source code or examples would help as well.

best regards,
valerio