Skip to content

Commit d85fb50

Browse files
committed
Пофиксил закрытие сервера отладки, добавил Dispose там, где его не было
1 parent e2b41cf commit d85fb50

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

src/OneScript.DebugProtocol/TcpServer/DefaultMessageServer.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public DefaultMessageServer(ICommunicationChannel protocolChannel)
2121
{
2222
_protocolChannel = protocolChannel;
2323
}
24+
25+
/// <summary>
26+
/// Имя, назначаемое потоку сервера. Полезно для отладки и диагностики.
27+
/// </summary>
28+
public string ServerThreadName { get; set; }
2429

2530
public void Start()
2631
{
@@ -76,6 +81,12 @@ private void RunCommandsLoop()
7681
}
7782
});
7883

84+
_messageThread.IsBackground = true;
85+
if (ServerThreadName != default)
86+
{
87+
_messageThread.Name = ServerThreadName;
88+
}
89+
7990
_messageThread.Start();
8091
}
8192

src/OneScript.DebugServices/MachineWaitToken.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,28 @@ This Source Code Form is subject to the terms of the
55
at http://mozilla.org/MPL/2.0/.
66
----------------------------------------------------------*/
77

8+
using System;
89
using System.Threading;
910
using ScriptEngine.Machine;
1011

1112
namespace OneScript.DebugServices
1213
{
13-
public class MachineWaitToken
14+
public class MachineWaitToken: IDisposable
1415
{
15-
private ManualResetEventSlim _threadEvent;
16+
private ManualResetEventSlim _threadEvent = new ManualResetEventSlim();
1617

17-
public MachineWaitToken()
18-
{
19-
_threadEvent = new ManualResetEventSlim();
20-
}
21-
2218
public MachineInstance Machine { get; set; }
2319

2420
public void Wait() => _threadEvent.Wait();
2521

2622
public void Set() => _threadEvent.Set();
2723

2824
public void Reset() => _threadEvent.Reset();
25+
26+
public void Dispose()
27+
{
28+
Machine.UnsetDebugMode();
29+
_threadEvent.Dispose();
30+
}
2931
}
3032
}

src/OneScript.DebugServices/ThreadManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public void Dispose()
8787
foreach (var machineWaitToken in tokens)
8888
{
8989
machineWaitToken.Machine.MachineStopped -= Machine_MachineStopped;
90+
machineWaitToken.Dispose();
9091
}
9192

9293
_machinesOnThreads.Clear();

src/ScriptEngine/ScriptingEngine.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public void SetCodeStatisticsCollector(ICodeStatCollector collector)
187187

188188
public void Dispose()
189189
{
190+
DebugController?.Dispose();
190191
AttachedScriptsFactory.SetInstance(null);
191192
GlobalsManager.Reset();
192193
}

0 commit comments

Comments
 (0)