Fixed race conditions.
This commit is contained in:
parent
c986db8b37
commit
d85b8b0797
1 changed files with 22 additions and 17 deletions
|
@ -137,8 +137,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
if task.key isnt key
|
if task.key isnt key
|
||||||
if task.active
|
if task.active
|
||||||
task.active = false
|
task.active = false
|
||||||
if task.isOnline()
|
@taskUpdate( task )
|
||||||
task.save()
|
|
||||||
else
|
else
|
||||||
changed = false
|
changed = false
|
||||||
if !task.active
|
if !task.active
|
||||||
|
@ -148,15 +147,13 @@ class _taskManagerSingleton extends App.Controller
|
||||||
changed = true
|
changed = true
|
||||||
task.notify = false
|
task.notify = false
|
||||||
if changed
|
if changed
|
||||||
if task.isOnline()
|
@taskUpdate( task )
|
||||||
task.save()
|
|
||||||
else
|
else
|
||||||
for task in tasks
|
for task in tasks
|
||||||
if @activeTask isnt task.key
|
if @activeTask isnt task.key
|
||||||
if task.active
|
if task.active
|
||||||
task.active = false
|
task.active = false
|
||||||
if task.isOnline()
|
@taskUpdate( task )
|
||||||
task.save()
|
|
||||||
|
|
||||||
# start worker for task if not exists
|
# start worker for task if not exists
|
||||||
@startController(key, callback, params, state, to_not_show)
|
@startController(key, callback, params, state, to_not_show)
|
||||||
|
@ -211,12 +208,9 @@ class _taskManagerSingleton extends App.Controller
|
||||||
task = @get( key )
|
task = @get( key )
|
||||||
if !task
|
if !task
|
||||||
throw "No such task with '#{key}' to update"
|
throw "No such task with '#{key}' to update"
|
||||||
@log 'notice', task.isOnline()
|
|
||||||
@log 'notice', task, task.id, task.isOnline()
|
|
||||||
return if !task.isOnline()
|
|
||||||
for item, value of params
|
for item, value of params
|
||||||
task.updateAttribute(item, value)
|
task[item] = value
|
||||||
App.Event.trigger 'task:render'
|
@taskUpdate( task )
|
||||||
|
|
||||||
remove: ( key, to_not_show = false ) =>
|
remove: ( key, to_not_show = false ) =>
|
||||||
task = @get( key )
|
task = @get( key )
|
||||||
|
@ -227,7 +221,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
if worker && worker.release
|
if worker && worker.release
|
||||||
worker.release()
|
worker.release()
|
||||||
@workersStarted[ key ] = false
|
@workersStarted[ key ] = false
|
||||||
task.destroy()
|
@taskDestroy(task)
|
||||||
App.Event.trigger 'task:render'
|
App.Event.trigger 'task:render'
|
||||||
|
|
||||||
notify: ( key ) =>
|
notify: ( key ) =>
|
||||||
|
@ -235,9 +229,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
if !task
|
if !task
|
||||||
throw "No such task with '#{key}' to notify"
|
throw "No such task with '#{key}' to notify"
|
||||||
task.notify = true
|
task.notify = true
|
||||||
if task.isOnline()
|
@taskUpdate( task )
|
||||||
task.save()
|
|
||||||
App.Event.trigger 'task:render'
|
|
||||||
|
|
||||||
reorder: ( order ) =>
|
reorder: ( order ) =>
|
||||||
prio = 0
|
prio = 0
|
||||||
|
@ -248,8 +240,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
prio++
|
prio++
|
||||||
if task.prio isnt prio
|
if task.prio isnt prio
|
||||||
task.prio = prio
|
task.prio = prio
|
||||||
if task.isOnline()
|
@taskUpdate( task )
|
||||||
task.save()
|
|
||||||
|
|
||||||
reset: =>
|
reset: =>
|
||||||
App.Taskbar.deleteAll()
|
App.Taskbar.deleteAll()
|
||||||
|
@ -260,6 +251,20 @@ class _taskManagerSingleton extends App.Controller
|
||||||
@TaskbarIdInt = Math.floor( Math.random() * 99999999 )
|
@TaskbarIdInt = Math.floor( Math.random() * 99999999 )
|
||||||
@TaskbarIdInt
|
@TaskbarIdInt
|
||||||
|
|
||||||
|
taskUpdate: (task) ->
|
||||||
|
@log 'notice', "UPDATE task #{task.id}"
|
||||||
|
update = ->
|
||||||
|
if task.isOnline()
|
||||||
|
task.save()
|
||||||
|
App.Event.trigger 'task:render'
|
||||||
|
#update()
|
||||||
|
@delay( update, 100, task.id, 'taskbar' )
|
||||||
|
|
||||||
|
taskDestroy: (task) ->
|
||||||
|
@clearDelay( task.id, 'taskbar' )
|
||||||
|
task.destroy()
|
||||||
|
App.Event.trigger 'task:render'
|
||||||
|
|
||||||
tasksInitial: =>
|
tasksInitial: =>
|
||||||
# reopen tasks
|
# reopen tasks
|
||||||
App.Event.trigger 'taskbar:init'
|
App.Event.trigger 'taskbar:init'
|
||||||
|
|
Loading…
Reference in a new issue