msys.shareGet
Last updated March 2020
Name
msys.shareGet — Retrieve the value associated with keystring set by an earlier call to msys.shareSet
Synopsis
msys.shareGet(keystring);
Description
Retrieves the value associated with keystring set by an earlier call to msys.shareSet. If there is no value associated with the keystring, this function returns nil. It returns true if the value was stored successfully, false otherwise. The most likely cause of failure is an invalid value for keystring.
Note
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 msys.lock("counter-example"); local c= msys.shareGet("my-counter"); if c == nil then c = 0; end msys.shareSet("my-counter", c + 1); msys.unlock("counter-example");
Because this function is in the msys namespace, an explicit require is not necessary.
See Also
Was this page helpful?