Change Ember.run.later to setTimeout in periodic actions

It seems that running Ember.run.later periodically can cause CPU usage
to increase over time. Such increase adds up to already increasing CPU
usage because of data amount growing.

This commit tries to mitigate the issue by using setTimeout instead
This commit is contained in:
Piotr Sarnacki 2013-05-29 11:15:07 +03:00
parent 3df9ee9723
commit 4288e79044
3 changed files with 5 additions and 5 deletions

View File

@ -9,7 +9,7 @@ Travis.RepoController = Travis.Controller.extend
init: ->
@_super.apply this, arguments
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
setTimeout(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
updateTimes: ->
if builds = @get('builds')
@ -21,7 +21,7 @@ Travis.RepoController = Travis.Controller.extend
if build && jobs = build.get('jobs')
jobs.forEach (j) -> j.updateTimes()
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
setTimeout(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
activate: (action) ->
@_unbind()

View File

@ -27,7 +27,7 @@ Travis.ReposController = Ember.ArrayController.extend
init: ->
@_super.apply this, arguments
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
setTimeout(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
recentRepos: (->
Travis.Repo.find()
@ -44,7 +44,7 @@ Travis.ReposController = Ember.ArrayController.extend
if content = @get('content')
content.forEach (r) -> r.updateTimes()
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
setTimeout(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
activate: (tab, params) ->
@set('sortProperties', null)

View File

@ -11,4 +11,4 @@
@schedule()
schedule: ->
Ember.run.later((=> @tick()), @get('interval') || Travis.TICK_INTERVAL)
setTimeout((=> @tick()), @get('interval') || Travis.TICK_INTERVAL)