diff --git a/lib/torque/provider/filterableJson.js b/lib/torque/provider/filterableJson.js index 37dccfe..006d9ab 100644 --- a/lib/torque/provider/filterableJson.js +++ b/lib/torque/provider/filterableJson.js @@ -66,11 +66,13 @@ var Profiler = require('../profiler'); getAvalaibleWorker:function(){ return this._workers.pop() }, + releaseWorker:function(worker){ console.log("releasing worker ", worker) this._workers.push(worker) this.processNextTileRequestInQueue() }, + processNextTileRequestInQueue:function(){ console.log("processing next ",this._tileProcessingQueue.length, this._workers.length ) if(this._tileProcessingQueue.length>0){ @@ -78,6 +80,7 @@ var Profiler = require('../profiler'); this.requestWorker(job.rows,job.coord,job.zoom, job.options, job.callback) } }, + requestWorker:function(rows,coord,zoom,options,callback){ worker = this.getAvalaibleWorker() self = this @@ -92,13 +95,14 @@ var Profiler = require('../profiler'); this.addToTileProcessingQueue(rows,coord,zoom,options,callback) } }, + addToTileProcessingQueue:function(rows,coord,zoom, options, callback){ this._tileProcessingQueue.push({rows:rows, coord:coord, zoom:zoom, options: options, callback:callback}) }, + /** * Creates a worker to process the tile */ - createProccessTileWorker:function(){ var workerFunction = "var proccessTile ="+ this.proccessTileSerial.toString() var wrapper = "; self.onmessage = function(e){var data = JSON.parse(e.data); JSON.stringify(self.postMessage(proccessTile(data.rows,data.coord, data.zoom, data.options)))}" @@ -124,6 +128,7 @@ var Profiler = require('../profiler'); this.requestWorker(rows,coord,zoom,workerSafeOptions,callback) } }, + /** * return the torque tile encoded in an efficient javascript * structure: