OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 */ | 7 */ |
8 WebInspector.FormatterWorkerPool = function() | 8 WebInspector.FormatterWorkerPool = function() |
9 { | 9 { |
10 this._taskQueue = []; | 10 this._taskQueue = []; |
11 /** @type {!Map<!WebInspector.Worker, ?WebInspector.FormatterWorkerPool.Task
>} */ | 11 /** @type {!Map<!WebInspector.Worker, ?WebInspector.FormatterWorkerPool.Task
>} */ |
12 this._workerTasks = new Map(); | 12 this._workerTasks = new Map(); |
13 } | 13 }; |
14 | 14 |
15 WebInspector.FormatterWorkerPool.MaxWorkers = 2; | 15 WebInspector.FormatterWorkerPool.MaxWorkers = 2; |
16 | 16 |
17 WebInspector.FormatterWorkerPool.prototype = { | 17 WebInspector.FormatterWorkerPool.prototype = { |
18 /** | 18 /** |
19 * @return {!WebInspector.Worker} | 19 * @return {!WebInspector.Worker} |
20 */ | 20 */ |
21 _createWorker: function() | 21 _createWorker: function() |
22 { | 22 { |
23 var worker = new WebInspector.Worker("formatter_worker"); | 23 var worker = new WebInspector.Worker("formatter_worker"); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 */ | 98 */ |
99 runTask: function(methodName, params) | 99 runTask: function(methodName, params) |
100 { | 100 { |
101 var callback; | 101 var callback; |
102 var promise = new Promise(fulfill => callback = fulfill); | 102 var promise = new Promise(fulfill => callback = fulfill); |
103 var task = new WebInspector.FormatterWorkerPool.Task(methodName, params,
callback, false); | 103 var task = new WebInspector.FormatterWorkerPool.Task(methodName, params,
callback, false); |
104 this._taskQueue.push(task); | 104 this._taskQueue.push(task); |
105 this._processNextTask(); | 105 this._processNextTask(); |
106 return promise; | 106 return promise; |
107 }, | 107 }, |
108 } | 108 }; |
109 | 109 |
110 /** | 110 /** |
111 * @constructor | 111 * @constructor |
112 * @param {string} method | 112 * @param {string} method |
113 * @param {!Object<string, string>} params | 113 * @param {!Object<string, string>} params |
114 * @param {function(?MessageEvent)} callback | 114 * @param {function(?MessageEvent)} callback |
115 * @param {boolean=} isChunked | 115 * @param {boolean=} isChunked |
116 */ | 116 */ |
117 WebInspector.FormatterWorkerPool.Task = function(method, params, callback, isChu
nked) | 117 WebInspector.FormatterWorkerPool.Task = function(method, params, callback, isChu
nked) |
118 { | 118 { |
119 this.method = method; | 119 this.method = method; |
120 this.params = params; | 120 this.params = params; |
121 this.callback = callback; | 121 this.callback = callback; |
122 this.isChunked = isChunked; | 122 this.isChunked = isChunked; |
123 } | 123 }; |
124 | 124 |
125 /** @type {!WebInspector.FormatterWorkerPool} */ | 125 /** @type {!WebInspector.FormatterWorkerPool} */ |
126 WebInspector.formatterWorkerPool; | 126 WebInspector.formatterWorkerPool; |
OLD | NEW |