Skip to content

Instantly share code, notes, and snippets.

@kaezarrex
Created November 9, 2012 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaezarrex/4046912 to your computer and use it in GitHub Desktop.
Save kaezarrex/4046912 to your computer and use it in GitHub Desktop.
Javascript Singleton Lock
var aquired = false,
lock;
function Lock() {
if (!lock) lock = this;
return lock;
}
Lock.prototype = {
getLock: function() {
if (aquired) return false;
aquired = true;
return true;
},
releaseLock: function() {
aquired = false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment