UNPKG

synapse_fs

Version:
42 lines (36 loc) 933 B
function ThreadCounter (threadCount) { this.threadId = 0; this.threadCount = threadCount; this.threadPathRegistry = {}; this.threadIdRegistry = {}; }; ThreadCounter.prototype.constructor = ThreadCounter; ThreadCounter.prototype.newThread = function newThread (data) { this.threadCount++; var threadId = ++this.threadId; this.threadPathRegistry[threadId] = data; this.threadIdRegistry[threadId] = threadId; return threadId; }; ThreadCounter.prototype.closeThread = function closeThread (threadId) { this.threadCount--; delete this.threadPathRegistry[threadId]; }; ThreadCounter.prototype.isActiveThread = function isActiveThread (threadId) { if (threadId in this.threadIdRegistry) return true; else return false; }; ThreadCounter.prototype.isDone = function isDone () { if (this.threadCount == 0) return true; else return false; }; module.exports = ThreadCounter;