lib/mw/Batcher.js
function Batcher(env) {
	this.env = env;
	this.itemCallbacks = {};
	this.currentBatch = [];
	this.pendingBatches = [];
	this.resultCache = {};
	this.numOutstanding = 0;
	this.forwardProgressTimer = null;
	this.maxBatchSize = env.conf.parsoid.batchSize;
	this.targetConcurrency = env.conf.parsoid.batchConcurrency;
	// Max latency before we give up on a batch response and terminate the req.
	this.maxResponseLatency = env.conf.parsoid.timeouts.mwApi.batch *
		(1 + env.conf.parsoid.retries.mwApi.all) + 5 * 1000;
}
function Batcher(env) {
	this.env = env;
	this.itemCallbacks = {};
	this.currentBatch = [];
	this.pendingBatches = [];
	this.resultCache = {};
	this.numOutstanding = 0;
	this.forwardProgressTimer = null;
	this.maxBatchSize = env.conf.parsoid.batchSize;
	this.targetConcurrency = env.conf.parsoid.batchConcurrency;
	// Max latency before we give up on a batch response and terminate the req.
	this.maxResponseLatency = env.conf.parsoid.timeouts.mwApi.batch *
		(1 + env.conf.parsoid.retries.mwApi.all) + 5 * 1000;
}
function Batcher ( env ) { this . env = env ; this . itemCallbacks = { } ; this . currentBatch = [ ] ; this . pendingBatches = [ ] ; this . resultCache = { } ; this . numOutstanding = 0 ; this . forwardProgressTimer = null ; this . maxBatchSize = env . conf . parsoid . batchSize ; this . targetConcurrency = env . conf . parsoid . batchConcurrency ; // Max latency before we give up on a batch response and terminate the req. this . maxResponseLatency = env . conf . parsoid . timeouts . mwApi . batch * ( 1 + env . conf . parsoid . retries . mwApi . all ) + 5 * 1000 ; }
This class combines requests into batches for dispatch to the
ParsoidBatchAPI extension, and calls the item callbacks when the batch
result is returned. It handles scheduling and concurrency of batch requests.
It also has a legacy mode which sends requests to the MW core API.

@class
@param {MWParserEnvironment} env
This class combines requests into batches for dispatch to the ParsoidBatchAPI extension and calls the item callbacks when the batch result is returned . It handles scheduling and concurrency of batch requests . It also has a legacy mode which sends requests to the MW core API .