Skip to content

Commit a3ce8d6

Browse files
committed
Keep Message in Fence job until Complete is done
Refs #1141
1 parent 32be305 commit a3ce8d6

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

source/server/lsp-job_schedulers.adb

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,23 @@ package body LSP.Job_Schedulers is
2525
(LSP.Server_Jobs.Server_Job'Class, LSP.Server_Jobs.Server_Job_Access);
2626

2727
procedure Complete_Last_Fence_Job
28-
(Self : in out Job_Scheduler'Class;
29-
Next : LSP.Server_Messages.Server_Message_Access);
28+
(Self : in out Job_Scheduler'Class;
29+
Next : LSP.Server_Messages.Server_Message_Access;
30+
Waste : out LSP.Server_Messages.Server_Message_Access);
3031
-- Call Complete on the last done Fence job (if any) and free it
3132

3233
-----------------------------
3334
-- Complete_Last_Fence_Job --
3435
-----------------------------
3536

3637
procedure Complete_Last_Fence_Job
37-
(Self : in out Job_Scheduler'Class;
38-
Next : LSP.Server_Messages.Server_Message_Access) is
38+
(Self : in out Job_Scheduler'Class;
39+
Next : LSP.Server_Messages.Server_Message_Access;
40+
Waste : out LSP.Server_Messages.Server_Message_Access) is
3941
begin
4042
if Self.Done.Assigned then
4143
Self.Done.Complete (Next);
44+
Waste := Self.Done.Message;
4245
Free (Self.Done);
4346
end if;
4447
end Complete_Last_Fence_Job;
@@ -116,22 +119,6 @@ package body LSP.Job_Schedulers is
116119
is
117120
use all type LSP.Server_Jobs.Job_Priority;
118121

119-
procedure Execute (Job : LSP.Server_Jobs.Server_Job_Access);
120-
121-
-------------
122-
-- Execute --
123-
-------------
124-
125-
procedure Execute (Job : LSP.Server_Jobs.Server_Job_Access) is
126-
begin
127-
Self.Complete_Last_Fence_Job (Job.Message);
128-
Waste := Job.Message;
129-
130-
while not Job.Is_Done loop
131-
Job.Execute (Client);
132-
end loop;
133-
end Execute;
134-
135122
Job : LSP.Server_Jobs.Server_Job_Access renames Self.Blocker;
136123
begin
137124
if not Job.Assigned then
@@ -149,12 +136,23 @@ package body LSP.Job_Schedulers is
149136
return;
150137
end if;
151138
end loop;
139+
end if;
140+
141+
Self.Complete_Last_Fence_Job (Job.Message, Waste);
152142

153-
Execute (Job);
143+
if Waste.Assigned and Job.Priority /= Fence then
144+
return;
145+
end if;
146+
147+
while not Job.Is_Done loop
148+
Job.Execute (Client);
149+
end loop;
150+
151+
if Job.Priority = Fence then
154152
Self.Done := Job; -- keep Job live till Complete call
155153
Job := null;
156154
else
157-
Execute (Job);
155+
Waste := Job.Message;
158156
Free (Job);
159157
end if;
160158
end Process_High_Priority_Job;
@@ -173,8 +171,13 @@ package body LSP.Job_Schedulers is
173171
declare
174172
Job : LSP.Server_Jobs.Server_Job_Access := List.First_Element;
175173
begin
174+
Self.Complete_Last_Fence_Job (Job.Message, Waste);
175+
176+
if Waste.Assigned then
177+
return;
178+
end if;
179+
176180
List.Delete_First;
177-
Self.Complete_Last_Fence_Job (Job.Message);
178181
Job.Execute (Client);
179182

180183
if Job.Is_Done then
@@ -189,7 +192,7 @@ package body LSP.Job_Schedulers is
189192
end;
190193
end loop;
191194

192-
Self.Complete_Last_Fence_Job (null);
195+
Self.Complete_Last_Fence_Job (null, Waste);
193196
end Process_Job;
194197

195198
----------------------

0 commit comments

Comments
 (0)