Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1fb86647
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1fb86647
编写于
12月 10, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support nested worker when running without iframe
上级
4dce6723
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
18 deletion
+52
-18
src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts
...nch/services/extensions/browser/webWorkerExtensionHost.ts
+33
-5
src/vs/workbench/services/extensions/common/polyfillNestedWorker.protocol.ts
...rvices/extensions/common/polyfillNestedWorker.protocol.ts
+18
-0
src/vs/workbench/services/extensions/worker/polyfillNestedWorker.ts
...kbench/services/extensions/worker/polyfillNestedWorker.ts
+1
-13
未找到文件。
src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts
浏览文件 @
1fb86647
...
...
@@ -30,6 +30,7 @@ import { canceled, onUnexpectedError } from 'vs/base/common/errors';
import
{
Barrier
}
from
'
vs/base/common/async
'
;
import
{
FileAccess
}
from
'
vs/base/common/network
'
;
import
{
ILayoutService
}
from
'
vs/platform/layout/browser/layoutService
'
;
import
{
NewWorkerMessage
,
TerminateWorkerMessage
}
from
'
vs/workbench/services/extensions/common/polyfillNestedWorker.protocol
'
;
export
interface
IWebWorkerExtensionHostInitData
{
readonly
autoStart
:
boolean
;
...
...
@@ -224,15 +225,42 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost
const
barrier
=
new
Barrier
();
let
port
!
:
MessagePort
;
const
nestedWorker
=
new
Map
<
string
,
Worker
>
();
worker
.
onmessage
=
(
event
)
=>
{
const
{
data
}
=
event
;
if
(
barrier
.
isOpen
()
||
!
(
data
instanceof
MessagePort
))
{
const
data
:
MessagePort
|
NewWorkerMessage
|
TerminateWorkerMessage
=
event
.
data
;
if
(
data
instanceof
MessagePort
)
{
// receiving a message port which is used to communicate
// with the web worker extension host
if
(
barrier
.
isOpen
())
{
console
.
warn
(
'
UNEXPECTED message
'
,
event
);
this
.
_onDidExit
.
fire
([
ExtensionHostExitCode
.
UnexpectedError
,
'
received a message port AFTER opening the barrier
'
]);
return
;
}
port
=
data
;
barrier
.
open
();
}
else
if
(
data
?.
type
===
'
_newWorker
'
)
{
// receiving a message to create a new nested/child worker
const
worker
=
new
Worker
(
data
.
url
,
data
.
options
);
worker
.
postMessage
(
data
.
port
,
[
data
.
port
]);
nestedWorker
.
set
(
data
.
id
,
worker
);
}
else
if
(
data
?.
type
===
'
_terminateWorker
'
)
{
// receiving a message to terminate nested/child worker
if
(
nestedWorker
.
has
(
data
.
id
))
{
nestedWorker
.
get
(
data
.
id
)
!
.
terminate
();
nestedWorker
.
delete
(
data
.
id
);
}
}
else
{
// all other messages are an error
console
.
warn
(
'
UNEXPECTED message
'
,
event
);
this
.
_onDidExit
.
fire
([
ExtensionHostExitCode
.
UnexpectedError
,
'
UNEXPECTED message
'
]);
return
;
}
port
=
data
;
barrier
.
open
();
};
// await MessagePort and use it to directly communicate
...
...
src/vs/workbench/services/extensions/common/polyfillNestedWorker.protocol.ts
0 → 100644
浏览文件 @
1fb86647
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export
interface
NewWorkerMessage
{
type
:
'
_newWorker
'
;
id
:
string
;
port
:
MessagePort
;
url
:
string
;
options
:
WorkerOptions
|
undefined
}
export
interface
TerminateWorkerMessage
{
type
:
'
_terminateWorker
'
;
id
:
string
;
}
src/vs/workbench/services/extensions/worker/polyfillNestedWorker.ts
浏览文件 @
1fb86647
...
...
@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
NewWorkerMessage
,
TerminateWorkerMessage
}
from
'
vs/workbench/services/extensions/common/polyfillNestedWorker.protocol
'
;
declare
function
postMessage
(
data
:
any
,
transferables
?:
Transferable
[]):
void
;
...
...
@@ -53,19 +54,6 @@ const _bootstrapFnSource = (function _bootstrapFn(workerUrl: string) {
}).
toString
();
interface
NewWorkerMessage
{
type
:
'
_newWorker
'
;
id
:
string
;
port
:
MessagePort
;
url
:
string
;
options
:
WorkerOptions
|
undefined
}
interface
TerminateWorkerMessage
{
type
:
'
_terminateWorker
'
;
id
:
string
;
}
export
class
NestedWorker
extends
EventTarget
implements
Worker
{
onmessage
:
((
this
:
Worker
,
ev
:
MessageEvent
<
any
>
)
=>
any
)
|
null
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录