mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
Only terminate worker after the worker completes work
This commit is contained in:
@@ -11,7 +11,7 @@ class LoadTextMatePackagesTask extends Task
|
||||
|
||||
loadNextPackage: ->
|
||||
unless @packages.length
|
||||
@terminate()
|
||||
@done()
|
||||
syntax.trigger 'grammars-loaded'
|
||||
return
|
||||
|
||||
|
||||
@@ -13,5 +13,5 @@ class LoadPathsTask extends Task
|
||||
@callWorkerMethod('loadPaths', rootPath, ignoredNames, excludeGitIgnoredPaths)
|
||||
|
||||
pathsLoaded: (paths) ->
|
||||
@terminate()
|
||||
@done()
|
||||
@callback(paths)
|
||||
|
||||
@@ -13,7 +13,7 @@ class LoadSnippetsTask extends Task
|
||||
|
||||
loadNextPackageSnippets: ->
|
||||
unless @packages.length
|
||||
@terminate()
|
||||
@done()
|
||||
@snippets.loaded = true
|
||||
return
|
||||
|
||||
|
||||
@@ -9,7 +9,10 @@ class Task
|
||||
|
||||
@worker = new Worker(require.getPath('task-shell'))
|
||||
@worker.onmessage = ({data}) =>
|
||||
return if @terminated
|
||||
if @terminated
|
||||
@done()
|
||||
return
|
||||
|
||||
if data.method and this[data.method]
|
||||
this[data.method](data.args...)
|
||||
else
|
||||
@@ -40,7 +43,9 @@ class Task
|
||||
@worker.postMessage(data)
|
||||
|
||||
terminate: ->
|
||||
unless @terminated
|
||||
@terminated = true
|
||||
@worker?.terminate()
|
||||
@worker = null
|
||||
@terminated = true
|
||||
|
||||
done: ->
|
||||
@terminate()
|
||||
@worker?.terminate()
|
||||
@worker = null
|
||||
|
||||
Reference in New Issue
Block a user