Locks a MUMPS global node using advisory locking. Note that this method uses MUMPS incremental locking.
jsm.lock(global, subscripts, timeout, callback);
Arguments
global
The MUMPS global name to be locked.
subscripts
An ECMAScript array indicating the subscript level at which to lock global
.
timeout
The duration in seconds that JSMumps should wait attempting to acquire the lock. If the lock cannot be acquired within this time, the err
argument to callback
will be set.
callback
The callback to be called when the lock is acquired or the attempt fails. Per Node.js conventions, this callback function takes two arguments, err and data.
Example
This example will try for 5 seconds to lock ^ACCOUNTS("bob")
const jsmumps = require('jsmumps');
const jsm = new jsmumps.JSMumps();
jsm.lock('ACCOUNTS', ['bob'], 5, (err, data) => {
if(err) {
console.log('Lock could not be acquired');
}
else {
console.log('Lock acquired successfully!');
}
});