mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-04 01:43:40 -04:00
Slightly less aggressively preload workers.
This commit is contained in:
parent
1097d56d50
commit
6505064fb6
1 changed files with 4 additions and 1 deletions
|
@ -13,6 +13,7 @@ module.exports = class God
|
||||||
@ids[@lastID]
|
@ids[@lastID]
|
||||||
|
|
||||||
maxAngels: 2 # how many concurrent web workers to use; if set past 8, make up more names
|
maxAngels: 2 # how many concurrent web workers to use; if set past 8, make up more names
|
||||||
|
maxWorkerPoolSize: 2 # ~20MB per idle worker
|
||||||
worldWaiting: false # whether we're waiting for a worker to free up and run the world
|
worldWaiting: false # whether we're waiting for a worker to free up and run the world
|
||||||
constructor: ->
|
constructor: ->
|
||||||
@id = God.nextID()
|
@id = God.nextID()
|
||||||
|
@ -30,8 +31,10 @@ module.exports = class God
|
||||||
fillWorkerPool: =>
|
fillWorkerPool: =>
|
||||||
return unless Worker
|
return unless Worker
|
||||||
@workerPool ?= []
|
@workerPool ?= []
|
||||||
while @workerPool.length < @maxAngels
|
if @workerPool.length < @maxWorkerPoolSize
|
||||||
@workerPool.push @createWorker()
|
@workerPool.push @createWorker()
|
||||||
|
if @workerPool.length < @maxWorkerPoolSize
|
||||||
|
@fillWorkerPool()
|
||||||
|
|
||||||
getWorker: ->
|
getWorker: ->
|
||||||
@fillWorkerPool()
|
@fillWorkerPool()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue