Module rcu
RCU-synchronized hash table.
Provides a concurrent hash table using Read-Copy-Update (RCU) synchronization.
Reads are lockless; writes are serialized. Keys are strings, values can be
booleans, integers, lunatik objects, or nil (to delete an entry).
See examples/shared.lua for a practical example.
Class rcu_table
| rcu_table:__index (key) | Retrieves a value from the table (RCU-protected, lockless). |
| rcu_table:__newindex (key, value) | Sets or removes a value in the table (serialized). |
| rcu_table:map (callback) | Iterates over the table calling callback(key, value) for each entry. |
rcu
| table ([size=256]) | Creates a new RCU hash table. |
Class rcu_table
RCU hash table object.
Supports table-like access via __index and __newindex.
Usage:
local t = rcu.table() t["key"] = true -- boolean t["n"] = 42 -- integer t["obj"] = data.new(8) -- object print(t["key"]) -- true t["key"] = nil -- delete
- rcu_table:__index (key)
-
Retrieves a value from the table (RCU-protected, lockless).
Parameters:
- key string
Returns:
-
boolean, integer, object or nil
- rcu_table:__newindex (key, value)
-
Sets or removes a value in the table (serialized).
Assigning
nilremoves the entry.Parameters:
- key string
- value boolean, integer, object or nil
Raises:
Error on memory allocation failure. - rcu_table:map (callback)
-
Iterates over the table calling
callback(key, value)for each entry. Iteration is RCU-protected; order is not guaranteed.Parameters:
- callback
function
function(key, value).
Raises:
Error if callback raises. - callback
function