-
Notifications
You must be signed in to change notification settings - Fork 50
/
DbgWorkerThread.pas
91 lines (70 loc) · 1.69 KB
/
DbgWorkerThread.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
unit DbgWorkerThread;
interface
uses System.Classes, System.SysUtils;
type
TDbgWorkerThread = class(TThread)
protected
procedure Execute; override;
public
constructor Create;
destructor Destroy; override;
procedure Stop;
class procedure Init; static;
class procedure Reset; static;
end;
var
gvDbgWorkerThread: TDbgWorkerThread = Nil;
implementation
uses Debuger;
{ TDbgWorkerThread }
constructor TDbgWorkerThread.Create;
begin
inherited Create(False);
FreeOnTerminate := False;
end;
destructor TDbgWorkerThread.Destroy;
begin
inherited;
end;
procedure TDbgWorkerThread.Execute;
var
HasNext: LongBool;
begin
NameThreadForDebugging(ClassName);
repeat
HasNext := False;
if Assigned(gvDebuger) then
begin
HasNext := gvDebuger.DbgSamplingProfiler.ProcessSamplingInfo;
HasNext := gvDebuger.DbgMemoryProfiler.ProcessMemoryInfoQueue or HasNext;
HasNext := gvDebuger.DbgSysncObjsProfiler.ProcessSyncObjsInfoQueue or HasNext;
if not HasNext then
Sleep(10);
end;
until Terminated and not(HasNext);
end;
class procedure TDbgWorkerThread.Init;
begin
if gvDebuger.CodeTracking or
gvDebuger.DbgMemoryProfiler.MemoryCheckMode or
gvDebuger.DbgSysncObjsProfiler.SyncObjsTracking
then
begin
if gvDbgWorkerThread = Nil then
gvDbgWorkerThread := TDbgWorkerThread.Create;
end;
end;
class procedure TDbgWorkerThread.Reset;
begin
if Assigned(gvDbgWorkerThread) then
begin
gvDbgWorkerThread.Stop;
FreeAndNil(gvDbgWorkerThread);
end;
end;
procedure TDbgWorkerThread.Stop;
begin
Terminate;
WaitFor;
end;
end.