Skip to main content


msys.shareSet — Associate a value with a keystring in the global share space


msys.shareSet(keystring, value);

keystring: string
value: string


This function associates a value with keystring in the global share space. This association is thread-safe and consistent across all Lua interpreters and co-routines. The act of setting the value is thread safe and does not require an explicit mutex, but it is recommended that you use a mutex to coordinate modification of the value. value may be a number, string, boolean or nil value.


This function has been made obsolete by the data sharing features introduced in version 3.2. For more information see msys.runInPool.

 incrementing a counter in a thread safe manner
local c= msys.shareGet("my-counter");
if c == nil then
  c = 0;
msys.shareSet("my-counter", c + 1);

Because this function is in the msys namespace, an explicit require is not necessary.

See Also

Was this page helpful?