/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @constructor
* @extends {WebInspector.Object}
*/
WebInspector.WorkerManager = function()
{
this._workerIdToWindow = {};
InspectorBackend.registerWorkerDispatcher(new WebInspector.DedicatedWorkerMessageForwarder(this));
}
WebInspector.WorkerManager.isWorkerFrontend = function()
{
return !!WebInspector.queryParamsObject["dedicatedWorkerId"] ||
!!WebInspector.queryParamsObject["isSharedWorker"];
}
WebInspector.WorkerManager.loaded = function()
{
var workerId = WebInspector.queryParamsObject["dedicatedWorkerId"];
if (workerId)
WebInspector.WorkerManager._initializeDedicatedWorkerFrontend(workerId);
else
WebInspector.workerManager = new WebInspector.WorkerManager();
if (WebInspector.WorkerManager.isWorkerFrontend())
WebInspector.WorkerManager._calculateWorkerInspectorTitle();
}
WebInspector.WorkerManager._initializeDedicatedWorkerFrontend = function(workerId)
{
function receiveMessage(event)
{
var message = event.data;
InspectorBackend.dispatch(message);
}
window.addEventListener("message", receiveMessage, true);
InspectorBackend.sendMessageObjectToBackend = function(message)
{
window.opener.postMessage({workerId: workerId, command: "sendMessageToBackend", message: message}, "*");
}
InspectorFrontendHost.loaded = function()
{
window.opener.postMessage({workerId: workerId, command: "loaded"}, "*");
}
}
WebInspector.WorkerManager._calculateWorkerInspectorTitle = function()
{
var expression = "location.href";
if (WebInspector.queryParamsObject["isSharedWorker"])
expression += " + (this.name ? ' (' + this.name + ')' : '')";
RuntimeAgent.evaluate.invoke({expression:expression, doNotPauseOnExceptions:true, returnByValue: true}, evalCallback.bind(this));
function evalCallback(error, result, wasThrown)
{
if (error || wasThrown) {
console.error(error);
return;
}
InspectorFrontendHost.inspectedURLChanged(result.value);
}
}
WebInspector.WorkerManager.Events = {
WorkerAdded: "worker-added",
WorkerRemoved: "worker-removed",
WorkersCleared: "workers-cleared",
WorkerInspectorClosed: "worker-inspector-closed"
}
WebInspector.WorkerManager.prototype = {
_workerCreated: function(workerId, url, inspectorConnected)
{
if (inspectorConnected)
this._openInspectorWindow(workerId);
this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkerAdded, {workerId: workerId, url: url, inspectorConnected: inspectorConnected});
},
_workerTerminated: function(workerId)
{
this.closeWorkerInspector(workerId);
this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkerRemoved, workerId);
},
_sendMessageToWorkerInspector: function(workerId, message)
{
var workerInspectorWindow = this._workerIdToWindow[workerId];
if (workerInspectorWindow)
workerInspectorWindow.postMessage(message, "*");
},
openWorkerInspector: function(workerId)
{
this._openInspectorWindow(workerId);
WorkerAgent.connectToWorker(workerId);
},
_openInspectorWindow: function(workerId)
{
var url = window.location.href + "&dedicatedWorkerId=" + workerId;
url = url.replace("docked=true&", "");
// Set location=0 just to make sure the front-end will be opened in a separate window, not in new tab.
var workerInspectorWindow = window.open(url, undefined, "location=0");
this._workerIdToWindow[workerId] = workerInspectorWindow;
workerInspectorWindow.addEventListener("beforeunload", this._workerInspectorClosing.bind(this, workerId), true);
// Listen to beforeunload in detached state and to the InspectorClosing event in case of attached inspector.
window.addEventListener("beforeunload", this._pageInspectorClosing.bind(this), true);
WebInspector.notifications.addEventListener(WebInspector.Events.InspectorClosing, this._pageInspectorClosing, this);
},
closeWorkerInspector: function(workerId)
{
var workerInspectorWindow = this._workerIdToWindow[workerId];
if (workerInspectorWindow)
workerInspectorWindow.close();
},
reset: function()
{
for (var workerId in this._workerIdToWindow)
this.closeWorkerInspector(workerId);
this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkersCleared);
},
_pageInspectorClosing: function()
{
this._ignoreWorkerInspectorClosing = true;
for (var workerId in this._workerIdToWindow) {
this._workerIdToWindow[workerId].close();
WorkerAgent.disconnectFromWorker(parseInt(workerId, 10));
}
},
_workerInspectorClosing: function(workerId, event)
{
if (this._ignoreWorkerInspectorClosing)
return;
delete this._workerIdToWindow[workerId];
WorkerAgent.disconnectFromWorker(workerId);
this.dispatchEventToListeners(WebInspector.WorkerManager.Events.WorkerInspectorClosed, workerId);
}
}
WebInspector.WorkerManager.prototype.__proto__ = WebInspector.Object.prototype;
/**
* @constructor
* @implements {WorkerAgent.Dispatcher}
*/
WebInspector.DedicatedWorkerMessageForwarder = function(workerManager)
{
this._workerManager = workerManager;
window.addEventListener("message", this._receiveMessage.bind(this), true);
}
WebInspector.DedicatedWorkerMessageForwarder.prototype = {
_receiveMessage: function(event)
{
var workerId = event.data["workerId"];
workerId = parseInt(workerId, 10);
var command = event.data.command;
var message = event.data.message;
if (command == "sendMessageToBackend")
WorkerAgent.sendMessageToWorker(workerId, message);
},
workerCreated: function(workerId, url, inspectorConnected)
{
this._workerManager._workerCreated(workerId, url, inspectorConnected);
},
workerTerminated: function(workerId)
{
this._workerManager._workerTerminated(workerId);
},
dispatchMessageFromWorker: function(workerId, message)
{
this._workerManager._sendMessageToWorkerInspector(workerId, message);
}
}
// Copyright 2007 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview This file implements a wrapper around the Gears WorkerPool
* with some extra features.
*
* @author arv@google.com (Erik Arvidsson)
*/
goog.provide('goog.gears.WorkerPool');
goog.provide('goog.gears.WorkerPool.Event');
goog.provide('goog.gears.WorkerPool.EventType');
goog.require('goog.events.Event');
goog.require('goog.events.EventTarget');
goog.require('goog.gears');
goog.require('goog.gears.Worker');
/**
* This class implements a wrapper around the Gears Worker Pool.
*
* @constructor
* @extends {goog.events.EventTarget}
*/
goog.gears.WorkerPool = function() {
goog.events.EventTarget.call(this);
/**
* Map from thread id to worker object
* @type {Object}
* @private
*/
this.workers_ = {};
// If we are in a worker thread we get the global google.gears.workerPool,
// otherwise we create a new Gears WorkerPool using the factory
var workerPool = /** @type {GearsWorkerPool} */
(goog.getObjectByName('google.gears.workerPool'));
if (workerPool) {
this.workerPool_ = workerPool;
} else {
// use a protected method to let the sub class override
this.workerPool_ = this.getGearsWorkerPool();
}
this.workerPool_.onmessage = goog.bind(this.handleMessage_, this);
};
goog.inherits(goog.gears.WorkerPool, goog.events.EventTarget);
/**
* Enum for event types fired by the WorkerPool.
* @enum {string}
*/
goog.gears.WorkerPool.EventType = {
UNKNOWN_WORKER: 'uknown_worker'
};
/**
* The Gears WorkerPool object.
* @type {GearsWorkerPool}
* @private
*/
goog.gears.WorkerPool.prototype.workerPool_ = null;
/**
* @return {GearsWorkerPool} A Gears WorkerPool object.
* @protected
*/
goog.gears.WorkerPool.prototype.getGearsWorkerPool = function() {
var factory = goog.gears.getFactory();
return factory.create('beta.workerpool');
};
/**
* Sets a last-chance error handler for a worker pool.
* WARNING: This will only succeed from inside a worker thread. In main thread,
* use window.onerror handler.
* @param {function(!GearsErrorObject):boolean} fn An error handler function
* that gets passed an error object with message and line number attributes.
* Returns whether the error was handled. If true stops propagation.
* @param {Object=} opt_handler This object for the function.
*/
goog.gears.WorkerPool.prototype.setErrorHandler = function(fn, opt_handler) {
this.workerPool_.onerror = goog.bind(fn, opt_handler);
};
/**
* Creates a new worker.
* @param {string} code The code to execute inside the worker.
* @return {goog.gears.Worker} The worker that was just created.
*/
goog.gears.WorkerPool.prototype.createWorker = function(code) {
var workerId = this.workerPool_.createWorker(code);
var worker = new goog.gears.Worker(this, workerId);
this.registerWorker(worker);
return worker;
};
/**
* Creates a new worker from a URL.
* @param {string} url URL from which to get the code to execute inside the
* worker.
* @return {goog.gears.Worker} The worker that was just created.
*/
goog.gears.WorkerPool.prototype.createWorkerFromUrl = function(url) {
var workerId = this.workerPool_.createWorkerFromUrl(url);
var worker = new goog.gears.Worker(this, workerId);
this.registerWorker(worker);
return worker;
};
/**
* Allows the worker who calls this to be used cross origin.
*/
goog.gears.WorkerPool.prototype.allowCrossOrigin = function() {
this.workerPool_.allowCrossOrigin();
};
/**
* Sends a message to a given worker.
* @param {*} message The message to send to the worker.
* @param {goog.gears.Worker} worker The worker to send the message to.
*/
goog.gears.WorkerPool.prototype.sendMessage = function(message, worker) {
this.workerPool_.sendMessage(message, worker.getId());
};
/**
* Callback when this worker recieves a message.
* @param {string} message The message that was sent.
* @param {number} senderId The ID of the worker that sent the message.
* @param {GearsMessageObject} messageObject An object containing all
* information about the message.
* @private
*/
goog.gears.WorkerPool.prototype.handleMessage_ = function(message,
senderId,
messageObject) {
if (!this.isDisposed()) {
var workers = this.workers_;
if (!workers[senderId]) {
// If the worker is unknown, dispatch an event giving users of the class
// the change to register the worker.
this.dispatchEvent(new goog.gears.WorkerPool.Event(
goog.gears.WorkerPool.EventType.UNKNOWN_WORKER,
senderId,
messageObject));
}
var worker = workers[senderId];
if (worker) {
worker.handleMessage(messageObject);
}
}
};
/**
* Registers a worker object.
* @param {goog.gears.Worker} worker The worker to register.
*/
goog.gears.WorkerPool.prototype.registerWorker = function(worker) {
this.workers_[worker.getId()] = worker;
};
/**
* Unregisters a worker object.
* @param {goog.gears.Worker} worker The worker to unregister.
*/
goog.gears.WorkerPool.prototype.unregisterWorker = function(worker) {
delete this.workers_[worker.getId()];
};
/** @override */
goog.gears.WorkerPool.prototype.disposeInternal = function() {
goog.gears.WorkerPool.superClass_.disposeInternal.call(this);
this.workerPool_ = null;
delete this.workers_;
};
/**
* Event used when the workerpool recieves a message
* @param {string} type The type of event.
* @param {number} senderId The id of the sender of the message.
* @param {GearsMessageObject} messageObject The message object.
*
* @constructor
* @extends {goog.events.Event}
*/
goog.gears.WorkerPool.Event = function(
type, senderId, messageObject) {
goog.events.Event.call(this, type);
/**
* The id of the sender of the message.
* @type {number}
*/
this.senderId = senderId;
/**
* The message sent from the worker. This is the same as the
* messageObject.body field and is here for convenience.
* @type {*}
*/
this.message = messageObject.body;
/**
* The object containing all information about the message.
* @type {GearsMessageObject}
*/
this.messageObject = messageObject;
};
goog.inherits(goog.gears.WorkerPool.Event, goog.events.Event);
(function() {
'use strict';
/**
* @ngdoc module
* @name appverse.performance
*
* @description
* The AppPerformance provides services to handle usage of several performance elements:
* 1. Webworkers. Multithreaded-parallelized execution of tasks separated of the main JavaScript thread.
* 2. High Performance UI directives support.
*
* @requires appverse.configuration
*/
run.$inject = ["$log"];
angular.module('appverse.performance', ['appverse.configuration'])
.run(run);
function run ($log) {
$log.info('appverse.performance run');
}
})();
(function () {
'use strict';
angular.module('appverse.performance')
/**
* @ngdoc directive
* @name webworker
* @module appverse.performance
* @restrict E
*
* @description
* Establishes comm with messages to a selected web worker.
* Allows send messages to the worker and receive results from.
* Messages from the worker are displayed in a div.
*
* @example
<example module="appverse.performance">
<file name="index.html">
<p>Web Worker test</p>
<webworker id="101" message="Hans Walter" template=""/>
</file>
</example>
*
* @param {string} id Id of the pre-configured worker or path to the worker's file
* @param {string} message Message to be passed to the worker.
*
* @requires https://docs.angularjs.org/api/ngMock/service/$log $log
* @requires WebWorkerFactory
* @requires PERFORMANCE_CONFIG
*/
.directive('webworker', ['$log', 'WebWorkerFactory', 'PERFORMANCE_CONFIG',
function ($log, WebWorkerFactory, PERFORMANCE_CONFIG) {
return {
restrict: 'E', //E = element, A = attribute, C = class, M = comment
scope: {
//(required) set the worker id in configuration or the complete path
//if it is not included in config.
workerid: '@',
//(required) set the message to be passed to the worker
message: '@',
//(optional) custom template to render the received message from the worker
template: '@'
},
priority: 1000,
terminal: true,
compile: function () {},
link: function postLink(scope, element, attrs) {
var workerid = attrs.id;
var template = attrs.template;
scope.$watch(function () {
return WebWorkerFactory._resultMessage;
}, function (newVal) {
$log.debug('Cache watch {' + name + '}:', newVal);
scope.messageFromWorker = WebWorkerFactory._resultMessage;
});
scope.$watch('message', function (value) {
init(value); // set defaults
compileTemplate(); // gets the template and compile the desired layout
});
/**
* @function
* @description
* Set defaults into the scope object
*/
function init(message) {
scope.workerid = workerid;
scope.template = template || PERFORMANCE_CONFIG.webworker_Message_template;
initWorker(scope.workerid, message);
}
/**
* @function
* @description
* Gets the message from the worker.
*/
function initWorker(workerid, message) {
WebWorkerFactory.runTask(workerid, message);
var messageFromWorker = WebWorkerFactory._resultMessage;
if (messageFromWorker) {
scope.messageFromWorker = messageFromWorker;
}
}
/**
* @function
* @description
* Gets the template and compile the desired layout.
* Based on $compile, it compiles a piece of HTML string or DOM into the retrieved
* template and produces a template function, which can then be used to link scope and
* the template together.
*/
function compileTemplate($http, $templateCache, $compile) {
$http.get(scope.template, {
//This allows you can get the template again by consuming the
//$templateCache service directly.
cache: $templateCache
})
.success(function (html) {
element.html(html);
$compile(element.contents())(scope);
});
}
}
};
}]);
})();
(function() {
'use strict';
WebWorkerPoolFactory.$inject = ["$log", "$q", "PERFORMANCE_CONFIG"];
angular.module('appverse.performance')
.factory('WebWorkerPoolFactory', WebWorkerPoolFactory);
/**
* @ngdoc service
* @name WebWorkerFactory
* @module appverse.performance
*
* @description
* This factory starts a pooled multithreaded execution of a webworker:
* <pre></code> _______
* | |-> thread 1
* USER -> message -> task -> | pool |-> thread 2
* |_______|-> thread N
* </code></pre>
*
* @requires https://docs.angularjs.org/api/ngMock/service/$q $q
* @requires https://docs.angularjs.org/api/ngMock/service/$log $log
* @requires PERFORMANCE_CONFIG
*/
function WebWorkerPoolFactory ($log, $q, PERFORMANCE_CONFIG) {
var factory = {
_poolSize: PERFORMANCE_CONFIG.webworker_pooled_threads,
_authorizedWorkersOnly: PERFORMANCE_CONFIG.webworker_authorized_workers_only,
_workersDir: PERFORMANCE_CONFIG.webworker_directory,
_workersList: PERFORMANCE_CONFIG.webworker_authorized_workers,
_resultMessage: ''
};
$log.debug("Initializated webworkers factory preconfigured values." );
$log.debug("Default pool size: " + factory._poolSize);
$log.debug("Are only authorized preconfigured workers? " + factory._authorizedWorkersOnly);
$log.debug("The folder for webworkers in the app: " + factory._workersDir);
$log.debug("Number of members in the workers list: " + factory._workersList.length);
/**
* @ngdoc method
* @name WebWorkerFactory#runParallelTasksGroup
*
* @param {number} workerData WorkerData object with information of the task to be executed
* @param {object} workerTasks Array with a group of WorkerTask objects for the same WorkerData
*
* @description
* Runs a group of parallelized tasks
* Run a set of workers according to the pre-defined data in configuration
* (id, type, size in pool and worker file).
* Pe-definition in configuration is mandatory.
* The group of tasks are up to the caller.
*/
factory.runParallelTasksGroup = function (workerData, workerTasks) {
this.workerData = workerData;
$log.debug("Started parallelized execution for worker: ");
$log.debug(workerData.toString());
//Initializes the pool with the indicated size for that worker group
var pool = new factory.WorkerPool(this.workerData.poolSize);
pool.init();
//Create a worker task for
if(workerTasks && workerTasks.length > 0){
// iterate through all the parts of the image
for (var x = 0; x < workerTasks.length; x++) {
var workerTask = workerTasks[x];
pool.addWorkerTask(workerTask);
}
}
return factory._resultMessage;
};
/**
* @ngdoc method
* @name WebWorkerFactory#passMessage
*
* @param {number} id of the called worker
* @param {object} function as callback
* @param {string} message to be passed to the worker
* @description
* Execute a task in a worker.
* The group of task is the same as the number indicated in the pool size for that pre-configured worker.
*/
factory.runTask = function (workerId, message, callback) {
var pool = new factory.WorkerPool(factory._poolSize);
pool.init();
/*
If only workers in the configuration file are allowed.
No fallback needed.
*/
var workerData;
var workerTask;
if(factory._authorizedWorkersOnly){
if(workerId){
//Get data from configuration for the worker from the provided ID
workerData = factory.getWorkerFromId(workerId);
}else{
//NO VALID WORKER ID ERROR
$log.error("NO VALID WORKER ID ERROR");
}
}else{
//If any provided worker is allowed the workerId arg is the complete path to the worker file
//The ID is not important here
if(workerId){
workerData = new WorkerData(1001, 'dedicated', workerId);
}else{
//NO VALID WORKER ID ERROR
$log.error("NO VALID WORKER ID ERROR");
}
}
if(workerData) {
pool = new factory.WorkerPool(workerData.poolSize);
/*
Create the worker task for the pool (only one task, passed N times):
workerName: File of the worker
callback: Register the supplied function as callback
message: The last argument will be used to send a message to the worker
*/
workerTask = new factory.WorkerTask(workerData, callback, message);
// Pass the worker task object to the execution pool.
// The default behavior is create one task for each thread in the pool.
for(var i = 0; i < factory._poolSize; i++){
pool.addWorkerTask(workerTask);
}
}else{
//NO WORKER DATA ERROR
$log.error("NO WORKER DATA ERROR");
}
//return _resultMessage;
};
factory.WorkerPool = function(poolSize) {
var _this = this;
if(!poolSize) {
this.size = factory._poolSize;
}else{
this.size = poolSize;
}
//Initialize some vars with default values
this.taskQueue = [];
this.workerQueue = [];
//Start the thread pool. To be used by the caller.
this.init = function() {
//Create the 'size' number of worker threads
for (var i = 0 ; i < _this.size ; i++) {
_this.workerQueue.push(new WorkerThread(_this));
}
};
this.addWorkerTask = function(workerTask) {
if (_this.workerQueue.length > 0) {
// get the worker from the front of the queue
var workerThread = _this.workerQueue.shift();
workerThread.run(workerTask);
} else {
// If there are not free workers the task is put in queue
_this.taskQueue.push(workerTask);
}
};
//Execute the queued task. If empty, put the task to the queue.
this.freeWorkerThread = function(workerThread) {
if (_this.taskQueue.length > 0) {
// It is not put back in the queue, but it is executed on the next task
var workerTask = _this.taskQueue.shift();
workerThread.run(workerTask);
} else {
_this.taskQueue.push(workerThread);
}
};
};
//Runner work tasks in the pool
function WorkerThread(parentPool) {
var _this = this;
this.parentPool = parentPool;
this.workerTask = {};
//Execute the task
this.run = function(workerTask) {
_this.workerTask = workerTask;
//Create a new web worker
if (_this.workerTask.script != null) {
/*
Creation of workers.
For both dedicated and shared workers, you can also attach to the
message event handler event type by using the addEventListener method.
*/
var worker;
if(workerTask.type == PERFORMANCE_CONFIG.webworker_dedicated_literal){
worker = new Worker(_this.workerTask.script);
worker.addEventListener('message', _this.OnWorkerMessageHandler, false);
worker.postMessage(_this.workerTask.startMessage);
}else if(workerTask.type == PERFORMANCE_CONFIG.webworker_shared_literal){
worker = new SharedWorker(_this.workerTask.script);
worker.port.addEventListener('message', _this.OnWorkerMessageHandler, false);
worker.port.postMessage(_this.workerTask.startMessage);
}else{
//NO TYPE ERROR
$log.error("NO VALID WORKER TYPE");
}
}
};
//We assume we only get a single callback from a worker as a handler
//It also indicates the end of this worker.
_this.OnWorkerMessageHandler = function (evt) {
// pass to original callback
_this.workerTask.callback(evt);
// We should use a separate thread to add the worker
_this.parentPool.freeWorkerThread(_this);
};
}
//The task to run
factory.WorkerTask = function (workerData, callback, msg) {
this.script = workerData.file;
if(callback){
this.callback = callback;
}else{
this.callback = defaultEventHandler;
}
this.startMessage = msg;
this.type = workerData.type;
};
/*
Default event handler.
*/
function defaultEventHandler(event){
factory._resultMessage = event.data;
}
//Data object for a worker
function WorkerData(workerId, type, poolSize, worker) {
this.id = workerId;
this.type = type;
this.poolSize = poolSize;
this.file = worker;
}
WorkerData.prototype.toString = function(){
return "ID: " + this.id + "|TYPE: " + this.type + "|POOL SIZE: " + this.poolSize + "|FILE: " + this.file;
};
//Extract worker information from configuration
factory.getWorkerFromId = function (workerId, poolSize){
this.id = workerId;
this.type = '';
this.poolSize = poolSize;
this.file = '';
for(var i = 0; i < factory._workersList.length; i++) {
if(factory._workersList[i].id === workerId){
this.type = factory._workersList[i].type;
if(!this.poolSize || this.poolSize == 0){
this.poolSize = factory._workersList[i].poolSize;
}else{
this.poolSize = poolSize;
}
this.file = factory._workersDir + factory._workersList[i].file;
break;
}
}
var workerData = new WorkerData(this.id, this.type, this.poolSize, this.file);
return workerData;
};
return factory;
}
})();
Accelerate Your Automation Test Cycles With LambdaTest
Leverage LambdaTestās cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.