Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
58c34085
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,发现更多精彩内容 >>
提交
58c34085
编写于
9月 06, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove forwarding of cancel via winjs promises in rpcProtocol (#56137)
上级
2b960fb0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
52 deletion
+21
-52
src/vs/workbench/services/extensions/node/lazyPromise.ts
src/vs/workbench/services/extensions/node/lazyPromise.ts
+5
-29
src/vs/workbench/services/extensions/node/rpcProtocol.ts
src/vs/workbench/services/extensions/node/rpcProtocol.ts
+15
-13
src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts
...rkbench/services/extensions/test/node/rpcProtocol.test.ts
+1
-10
未找到文件。
src/vs/workbench/services/extensions/node/lazyPromise.ts
浏览文件 @
58c34085
...
...
@@ -7,9 +7,7 @@
import
{
TPromise
,
ValueCallback
,
ErrorCallback
}
from
'
vs/base/common/winjs.base
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
export
class
LazyPromise
implements
TPromise
<
any
>
{
private
_onCancel
:
()
=>
void
;
export
class
LazyPromise
implements
Thenable
<
any
>
{
private
_actual
:
TPromise
<
any
>
;
private
_actualOk
:
ValueCallback
;
...
...
@@ -21,10 +19,7 @@ export class LazyPromise implements TPromise<any> {
private
_hasErr
:
boolean
;
private
_err
:
any
;
private
_isCanceled
:
boolean
;
constructor
(
onCancel
:
()
=>
void
)
{
this
.
_onCancel
=
onCancel
;
constructor
()
{
this
.
_actual
=
null
;
this
.
_actualOk
=
null
;
this
.
_actualErr
=
null
;
...
...
@@ -32,7 +27,6 @@ export class LazyPromise implements TPromise<any> {
this
.
_value
=
null
;
this
.
_hasErr
=
false
;
this
.
_err
=
null
;
this
.
_isCanceled
=
false
;
}
private
_ensureActual
():
TPromise
<
any
>
{
...
...
@@ -40,7 +34,7 @@ export class LazyPromise implements TPromise<any> {
this
.
_actual
=
new
TPromise
<
any
>
((
c
,
e
)
=>
{
this
.
_actualOk
=
c
;
this
.
_actualErr
=
e
;
}
,
this
.
_onCancel
);
});
if
(
this
.
_hasValue
)
{
this
.
_actualOk
(
this
.
_value
);
...
...
@@ -54,7 +48,7 @@ export class LazyPromise implements TPromise<any> {
}
public
resolveOk
(
value
:
any
):
void
{
if
(
this
.
_
isCanceled
||
this
.
_hasErr
)
{
if
(
this
.
_
hasValue
||
this
.
_hasErr
)
{
return
;
}
...
...
@@ -67,7 +61,7 @@ export class LazyPromise implements TPromise<any> {
}
public
resolveErr
(
err
:
any
):
void
{
if
(
this
.
_
isCanceled
||
this
.
_hasValue
)
{
if
(
this
.
_
hasValue
||
this
.
_hasErr
)
{
return
;
}
...
...
@@ -84,24 +78,6 @@ export class LazyPromise implements TPromise<any> {
}
public
then
(
success
:
any
,
error
:
any
):
any
{
if
(
this
.
_isCanceled
)
{
return
;
}
return
this
.
_ensureActual
().
then
(
success
,
error
);
}
public
cancel
():
void
{
if
(
this
.
_hasValue
||
this
.
_hasErr
)
{
return
;
}
this
.
_isCanceled
=
true
;
if
(
this
.
_actual
)
{
this
.
_actual
.
cancel
();
}
else
{
this
.
_onCancel
();
}
}
}
src/vs/workbench/services/extensions/node/rpcProtocol.ts
浏览文件 @
58c34085
...
...
@@ -96,6 +96,8 @@ export interface IRPCProtocolLogger {
logOutgoing
(
msgLength
:
number
,
req
:
number
,
initiator
:
RequestInitiator
,
str
:
string
,
data
?:
any
):
void
;
}
const
noop
=
()
=>
{
};
export
class
RPCProtocol
implements
IRPCProtocol
{
private
readonly
_protocol
:
IMessagePassingProtocol
;
...
...
@@ -249,7 +251,7 @@ export class RPCProtocol implements IRPCProtocol {
}
const
callId
=
String
(
req
);
let
promise
:
T
Promis
e
<
any
>
;
let
promise
:
T
henabl
e
<
any
>
;
let
cancel
:
()
=>
void
;
if
(
usesCancellationToken
)
{
const
cancellationTokenSource
=
new
CancellationTokenSource
();
...
...
@@ -257,8 +259,9 @@ export class RPCProtocol implements IRPCProtocol {
promise
=
this
.
_invokeHandler
(
rpcId
,
method
,
args
);
cancel
=
()
=>
cancellationTokenSource
.
cancel
();
}
else
{
// cannot be cancelled
promise
=
this
.
_invokeHandler
(
rpcId
,
method
,
args
);
cancel
=
()
=>
promise
.
cancel
()
;
cancel
=
noop
;
}
this
.
_cancelInvokedHandlers
[
callId
]
=
cancel
;
...
...
@@ -331,7 +334,7 @@ export class RPCProtocol implements IRPCProtocol {
pendingReply
.
resolveErr
(
err
);
}
private
_invokeHandler
(
rpcId
:
number
,
methodName
:
string
,
args
:
any
[]):
T
Promis
e
<
any
>
{
private
_invokeHandler
(
rpcId
:
number
,
methodName
:
string
,
args
:
any
[]):
T
henabl
e
<
any
>
{
try
{
return
TPromise
.
as
(
this
.
_doInvokeHandler
(
rpcId
,
methodName
,
args
));
}
catch
(
err
)
{
...
...
@@ -351,7 +354,7 @@ export class RPCProtocol implements IRPCProtocol {
return
method
.
apply
(
actor
,
args
);
}
private
_remoteCall
(
rpcId
:
number
,
methodName
:
string
,
args
:
any
[]):
T
Promis
e
<
any
>
{
private
_remoteCall
(
rpcId
:
number
,
methodName
:
string
,
args
:
any
[]):
T
henabl
e
<
any
>
{
if
(
this
.
_isDisposed
)
{
return
TPromise
.
wrapError
<
any
>
(
errors
.
canceled
());
}
...
...
@@ -367,17 +370,16 @@ export class RPCProtocol implements IRPCProtocol {
const
req
=
++
this
.
_lastMessageId
;
const
callId
=
String
(
req
);
const
sendCancel
=
()
=>
{
const
msg
=
MessageIO
.
serializeCancel
(
req
);
if
(
this
.
_logger
)
{
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
req
,
RequestInitiator
.
LocalSide
,
`cancel`
);
}
this
.
_protocol
.
send
(
MessageIO
.
serializeCancel
(
req
));
};
const
result
=
new
LazyPromise
(
sendCancel
);
const
result
=
new
LazyPromise
();
if
(
cancellationToken
)
{
cancellationToken
.
onCancellationRequested
(
sendCancel
);
cancellationToken
.
onCancellationRequested
(()
=>
{
const
msg
=
MessageIO
.
serializeCancel
(
req
);
if
(
this
.
_logger
)
{
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
req
,
RequestInitiator
.
LocalSide
,
`cancel`
);
}
this
.
_protocol
.
send
(
MessageIO
.
serializeCancel
(
req
));
});
}
this
.
_pendingRPCReplies
[
callId
]
=
result
;
...
...
src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts
浏览文件 @
58c34085
...
...
@@ -35,7 +35,7 @@ suite('RPCProtocol', () => {
let
delegate
:
(
a1
:
any
,
a2
:
any
)
=>
any
;
let
bProxy
:
BClass
;
class
BClass
{
$m
(
a1
:
any
,
a2
:
any
):
T
Promis
e
<
any
>
{
$m
(
a1
:
any
,
a2
:
any
):
T
henabl
e
<
any
>
{
return
TPromise
.
as
(
delegate
.
call
(
null
,
a1
,
a2
));
}
}
...
...
@@ -108,15 +108,6 @@ suite('RPCProtocol', () => {
},
done
);
});
test
(
'
cancelling a call
'
,
function
()
{
delegate
=
(
a1
:
number
,
a2
:
number
)
=>
a1
+
a2
;
let
p
=
bProxy
.
$m
(
4
,
1
);
p
.
then
((
res
:
number
)
=>
{
assert
.
fail
(
'
should not receive result
'
);
});
p
.
cancel
();
});
test
(
'
cancelling a call via CancellationToken before
'
,
function
(
done
)
{
delegate
=
(
a1
:
number
,
a2
:
number
)
=>
a1
+
a2
;
let
p
=
bProxy
.
$m
(
4
,
CancellationToken
.
Cancelled
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录