bitcore-wallet-service/lib/lock.js

21 lines
433 B
JavaScript
Raw Normal View History

2015-04-03 11:43:22 -07:00
var $ = require('preconditions').singleton();
2015-04-07 13:02:08 -07:00
var _ = require('lodash');
var LocalLock = require('./locallock');
var RemoteLock = require('locker');
2015-01-27 05:18:45 -08:00
2015-04-07 13:02:08 -07:00
function Lock(opts) {};
2015-01-27 05:18:45 -08:00
2015-04-07 13:02:08 -07:00
Lock.prototype.runLocked = function(token, cb, task) {
$.shouldBeDefined(token);
2015-01-27 05:18:45 -08:00
2015-04-07 13:02:08 -07:00
LocalLock.get(token, function(lock) {
var _cb = function() {
cb.apply(null, arguments);
lock.free();
};
task(_cb);
});
2015-01-27 05:18:45 -08:00
};
module.exports = Lock;