Skip to content

Commit f1be4b6

Browse files
committed
Got rid of lock object and locks. Rely upon serialized handling of messages.
1 parent 5e6f755 commit f1be4b6

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class DebugAdapter : DebugAdapterBase
2020
{
2121
private EditorSession editorSession;
2222
private OutputDebouncer outputDebouncer;
23-
private object syncLock = new object();
2423
private bool isConfigurationDoneRequestComplete;
2524
private bool isLaunchRequestComplete;
2625
private string scriptPathToLaunch;
@@ -105,16 +104,6 @@ protected async Task HandleConfigurationDoneRequest(
105104
object args,
106105
RequestContext<object> requestContext)
107106
{
108-
// Ensure that only the second message between launch and
109-
// configurationDone requests, actually launches the script.
110-
lock (syncLock)
111-
{
112-
if (!this.isLaunchRequestComplete)
113-
{
114-
this.isConfigurationDoneRequestComplete = true;
115-
}
116-
}
117-
118107
// The order of debug protocol messages apparently isn't as guaranteed as we might like.
119108
// Need to be able to handle the case where we get the configurationDone request after the
120109
// launch request.
@@ -123,6 +112,8 @@ protected async Task HandleConfigurationDoneRequest(
123112
this.LaunchScript(requestContext);
124113
}
125114

115+
this.isConfigurationDoneRequestComplete = true;
116+
126117
await requestContext.SendResult(null);
127118
}
128119

@@ -167,16 +158,6 @@ protected async Task HandleLaunchRequest(
167158
this.scriptPathToLaunch = launchParams.Program;
168159
this.arguments = arguments;
169160

170-
// Ensure that only the second message between launch and
171-
// configurationDone requests, actually launches the script.
172-
lock (syncLock)
173-
{
174-
if (!this.isConfigurationDoneRequestComplete)
175-
{
176-
this.isLaunchRequestComplete = true;
177-
}
178-
}
179-
180161
// The order of debug protocol messages apparently isn't as guaranteed as we might like.
181162
// Need to be able to handle the case where we get the launch request after the
182163
// configurationDone request.
@@ -185,6 +166,8 @@ protected async Task HandleLaunchRequest(
185166
this.LaunchScript(requestContext);
186167
}
187168

169+
this.isLaunchRequestComplete = true;
170+
188171
await requestContext.SendResult(null);
189172
}
190173

0 commit comments

Comments
 (0)