docs: function lock(key) {
      var promise = new Promise(function(resolve, reject) {
  
          wait(key, function(key) {
              var released = false;
              var lock = function() {
                  if (!released) {
                      free(key);
                      released = true;
                  }
              };
              lock.key = key;
  
              resolve(lock);
          });
      });
  
      tick(key);
  
      return promise;
  }