reddit plugin configuration from file, not from options now. Scheduling, refactoring of sync mutex

This commit is contained in:
azivner
2018-01-13 22:51:39 -05:00
parent fbfaff6ab8
commit 9839ea019e
5 changed files with 63 additions and 49 deletions

View File

@@ -4,5 +4,20 @@
*/
const Mutex = require('async-mutex').Mutex;
const instance = new Mutex();
module.exports = new Mutex();
async function doExclusively(func) {
const releaseMutex = await instance.acquire();
try {
await func();
}
finally {
releaseMutex();
}
}
module.exports = {
doExclusively
};