modified such that locking now returns a lock ID to the callback which must be used to unlock

added jsdoc comments