Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
79791f91
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
79791f91
编写于
7月 28, 2020
作者:
S
Sam Harwell
提交者:
GitHub
7月 28, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #46346 from sharwell/updaterservice-test
Fix race condition in SolutionChecksumUpdater work queue
上级
cd2d2d7c
bb69323f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
16 deletion
+20
-16
src/VisualStudio/Core/Def/Implementation/Remote/SolutionChecksumUpdater.cs
...Core/Def/Implementation/Remote/SolutionChecksumUpdater.cs
+19
-15
src/VisualStudio/Core/Test.Next/Remote/RemoteHostClientServiceFactoryTests.cs
...e/Test.Next/Remote/RemoteHostClientServiceFactoryTests.cs
+1
-1
未找到文件。
src/VisualStudio/Core/Def/Implementation/Remote/SolutionChecksumUpdater.cs
浏览文件 @
79791f91
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
using
Microsoft.CodeAnalysis.Remote
;
using
Microsoft.CodeAnalysis.Remote
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Microsoft.CodeAnalysis.SolutionCrawler
;
using
Microsoft.CodeAnalysis.SolutionCrawler
;
using
Microsoft.VisualStudio.Threading
;
using
Roslyn.Utilities
;
using
Roslyn.Utilities
;
namespace
Microsoft.VisualStudio.LanguageServices.Remote
namespace
Microsoft.VisualStudio.LanguageServices.Remote
...
@@ -18,13 +19,13 @@ internal sealed class SolutionChecksumUpdater : GlobalOperationAwareIdleProcesso
...
@@ -18,13 +19,13 @@ internal sealed class SolutionChecksumUpdater : GlobalOperationAwareIdleProcesso
{
{
private
readonly
Workspace
_workspace
;
private
readonly
Workspace
_workspace
;
private
readonly
TaskQueue
_textChangeQueue
;
private
readonly
TaskQueue
_textChangeQueue
;
private
readonly
SemaphoreSlim
_event
;
private
readonly
AsyncQueue
<
IAsyncToken
>
_workQueue
;
private
readonly
object
_gate
;
private
readonly
object
_gate
;
private
CancellationTokenSource
_globalOperationCancellationSource
;
private
CancellationTokenSource
_globalOperationCancellationSource
;
// hold
last async token
// hold
the async token from WaitAsync so ExecuteAsync can complete it
private
IAsyncToken
_
las
tToken
;
private
IAsyncToken
_
curren
tToken
;
public
SolutionChecksumUpdater
(
Workspace
workspace
,
IAsynchronousOperationListenerProvider
listenerProvider
,
CancellationToken
shutdownToken
)
public
SolutionChecksumUpdater
(
Workspace
workspace
,
IAsynchronousOperationListenerProvider
listenerProvider
,
CancellationToken
shutdownToken
)
:
base
(
listenerProvider
.
GetListener
(
FeatureAttribute
.
SolutionChecksumUpdater
),
:
base
(
listenerProvider
.
GetListener
(
FeatureAttribute
.
SolutionChecksumUpdater
),
...
@@ -34,7 +35,7 @@ public SolutionChecksumUpdater(Workspace workspace, IAsynchronousOperationListen
...
@@ -34,7 +35,7 @@ public SolutionChecksumUpdater(Workspace workspace, IAsynchronousOperationListen
_workspace
=
workspace
;
_workspace
=
workspace
;
_textChangeQueue
=
new
TaskQueue
(
Listener
,
TaskScheduler
.
Default
);
_textChangeQueue
=
new
TaskQueue
(
Listener
,
TaskScheduler
.
Default
);
_
event
=
new
SemaphoreSlim
(
initialCount
:
0
);
_
workQueue
=
new
AsyncQueue
<
IAsyncToken
>(
);
_gate
=
new
object
();
_gate
=
new
object
();
// start listening workspace change event
// start listening workspace change event
...
@@ -52,8 +53,9 @@ protected override async Task ExecuteAsync()
...
@@ -52,8 +53,9 @@ protected override async Task ExecuteAsync()
{
{
lock
(
_gate
)
lock
(
_gate
)
{
{
_lastToken
?.
Dispose
();
Contract
.
ThrowIfNull
(
_currentToken
);
_lastToken
=
null
;
_currentToken
.
Dispose
();
_currentToken
=
null
;
}
}
// wait for global operation to finish
// wait for global operation to finish
...
@@ -73,8 +75,15 @@ protected override void PauseOnGlobalOperation()
...
@@ -73,8 +75,15 @@ protected override void PauseOnGlobalOperation()
CancelAndDispose
(
previousCancellationSource
);
CancelAndDispose
(
previousCancellationSource
);
}
}
protected
override
Task
WaitAsync
(
CancellationToken
cancellationToken
)
protected
override
async
Task
WaitAsync
(
CancellationToken
cancellationToken
)
=>
_event
.
WaitAsync
(
cancellationToken
);
{
var
currentToken
=
await
_workQueue
.
DequeueAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
lock
(
_gate
)
{
Contract
.
ThrowIfFalse
(
_currentToken
is
null
);
_currentToken
=
currentToken
;
}
}
public
override
void
Shutdown
()
public
override
void
Shutdown
()
{
{
...
@@ -102,17 +111,12 @@ private void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs e)
...
@@ -102,17 +111,12 @@ private void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs e)
private
void
EnqueueChecksumUpdate
()
private
void
EnqueueChecksumUpdate
()
{
{
// event will raised sequencially. no concurrency on this handler
// event will raised sequencially. no concurrency on this handler
if
(
_
event
.
CurrentCount
>
0
)
if
(
_
workQueue
.
TryPeek
(
out
_
)
)
{
{
return
;
return
;
}
}
lock
(
_gate
)
_workQueue
.
Enqueue
(
Listener
.
BeginAsyncOperation
(
nameof
(
SolutionChecksumUpdater
)));
{
_lastToken
??=
Listener
.
BeginAsyncOperation
(
nameof
(
SolutionChecksumUpdater
));
}
_event
.
Release
();
}
}
private
async
Task
SynchronizePrimaryWorkspaceAsync
(
CancellationToken
cancellationToken
)
private
async
Task
SynchronizePrimaryWorkspaceAsync
(
CancellationToken
cancellationToken
)
...
...
src/VisualStudio/Core/Test.Next/Remote/RemoteHostClientServiceFactoryTests.cs
浏览文件 @
79791f91
...
@@ -30,7 +30,7 @@ public class RemoteHostClientServiceFactoryTests
...
@@ -30,7 +30,7 @@ public class RemoteHostClientServiceFactoryTests
private
static
AdhocWorkspace
CreateWorkspace
()
private
static
AdhocWorkspace
CreateWorkspace
()
=>
new
AdhocWorkspace
(
s_composition
.
GetHostServices
());
=>
new
AdhocWorkspace
(
s_composition
.
GetHostServices
());
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/46255"
)
]
[
Fact
]
public
async
Task
UpdaterService
()
public
async
Task
UpdaterService
()
{
{
var
hostServices
=
s_composition
.
GetHostServices
();
var
hostServices
=
s_composition
.
GetHostServices
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录