synapse_fs
Version:
A simple file search utility.
42 lines (36 loc) • 933 B
JavaScript
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;