Sha256: 01ecb9f730b3e93c5b20839fe99d4054d2b5bc03cb4a98dc5e3a63eeaa1278e2
Contents?: true
Size: 621 Bytes
Versions: 3
Compression:
Stored size: 621 Bytes
Contents
// This is a free list to avoid creating so many of the same object. exports.FreeList = function(name, max, constructor) { this.name = name; this.constructor = constructor; this.max = max; this.list = []; } exports.FreeList.prototype.alloc = function () { //debug("alloc " + this.name + " " + this.list.length); return this.list.length ? this.list.shift() : this.constructor.apply(this, arguments); }; exports.FreeList.prototype.free = function (obj) { //debug("free " + this.name + " " + this.list.length); if (this.list.length < this.max) { this.list.push(obj); } };
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rednode-0.1.2 | ext/node/lib/freelist.js |
rednode-0.1.1 | ext/node/lib/freelist.js |
rednode-0.1.0 | ext/node/lib/freelist.js |