Skip to content

Commit e8e897b

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 349c921 + 7b861b8 commit e8e897b

File tree

3 files changed

+44
-48
lines changed

3 files changed

+44
-48
lines changed

source/server/lsp-job_schedulers.adb

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ package body LSP.Job_Schedulers is
5252

5353
procedure Create_Job
5454
(Self : in out Job_Scheduler'Class;
55-
Message : in out LSP.Server_Messages.Server_Message_Access)
55+
Message : in out LSP.Server_Messages.Server_Message_Access;
56+
Waste : out LSP.Server_Messages.Server_Message_Access)
5657
is
5758
Cursor : constant Handler_Maps.Cursor :=
5859
Self.Handlers.Find (Message'Tag);
@@ -61,6 +62,7 @@ package body LSP.Job_Schedulers is
6162
begin
6263
if Handler_Maps.Has_Element (Cursor) then
6364

65+
Self.Complete_Last_Fence_Job (Message, Waste);
6466
Job := Handler_Maps.Element (Cursor).Create_Job (Message);
6567

6668
if Job.Assigned then
@@ -123,9 +125,9 @@ package body LSP.Job_Schedulers is
123125
Job : LSP.Server_Jobs.Server_Job_Access renames Self.Blocker;
124126
Status : LSP.Server_Jobs.Execution_Status := Continue;
125127
begin
126-
if not Job.Assigned then
127-
Waste := null;
128+
Waste := null;
128129

130+
if not Job.Assigned then
129131
return;
130132
end if;
131133

@@ -140,12 +142,6 @@ package body LSP.Job_Schedulers is
140142
end loop;
141143
end if;
142144

143-
Self.Complete_Last_Fence_Job (Job.Message, Waste);
144-
145-
if Waste.Assigned and Job.Priority /= Fence then
146-
return;
147-
end if;
148-
149145
while Status /= LSP.Server_Jobs.Done loop
150146
Job.Execute (Client, Status);
151147
end loop;
@@ -164,27 +160,24 @@ package body LSP.Job_Schedulers is
164160
-----------------
165161

166162
procedure Process_Job
167-
(Self : in out Job_Scheduler'Class;
168-
Client :
163+
(Self : in out Job_Scheduler'Class;
164+
Client :
169165
in out LSP.Client_Message_Receivers.Client_Message_Receiver'Class;
170-
Waste : out LSP.Server_Messages.Server_Message_Access)
166+
Waste : out LSP.Server_Messages.Server_Message_Access)
171167
is
172168
Status : LSP.Server_Jobs.Execution_Status;
173169
begin
174-
for List of reverse Self.Jobs when not List.Is_Empty loop
175-
declare
176-
Job : LSP.Server_Jobs.Server_Job_Access := List.First_Element;
177-
begin
178-
Self.Complete_Last_Fence_Job (Job.Message, Waste);
179-
180-
if Waste.Assigned then
181-
return;
182-
end if;
170+
Self.Complete_Last_Fence_Job (null, Waste);
183171

184-
List.Delete_First;
185-
Job.Execute (Client, Status);
172+
if not Waste.Assigned then
173+
for List of reverse Self.Jobs when not List.Is_Empty loop
174+
declare
175+
Job : LSP.Server_Jobs.Server_Job_Access := List.First_Element;
176+
begin
177+
List.Delete_First;
178+
Job.Execute (Client, Status);
186179

187-
case Status is
180+
case Status is
188181

189182
when LSP.Server_Jobs.Done =>
190183
Waste := Job.Message;
@@ -193,13 +186,12 @@ package body LSP.Job_Schedulers is
193186
when LSP.Server_Jobs.Continue =>
194187
Waste := null;
195188
List.Append (Job); -- Push the job back to the queue
196-
end case;
189+
end case;
197190

198-
exit;
199-
end;
200-
end loop;
201-
202-
Self.Complete_Last_Fence_Job (null, Waste);
191+
exit;
192+
end;
193+
end loop;
194+
end if;
203195
end Process_Job;
204196

205197
----------------------

source/server/lsp-job_schedulers.ads

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,36 @@ package LSP.Job_Schedulers is
4040

4141
procedure Create_Job
4242
(Self : in out Job_Scheduler'Class;
43-
Message : in out LSP.Server_Messages.Server_Message_Access);
43+
Message : in out LSP.Server_Messages.Server_Message_Access;
44+
Waste : out LSP.Server_Messages.Server_Message_Access);
4445
-- Create a job to process a server message. The scheduler takes ownership
4546
-- of the message and will return it to the server when the job is done.
4647
-- If there is no handler for the message, then the scheduler doesn't
4748
-- accept message and server should destroy it.
49+
-- This call completes a high priority job (if any) and returns its message
50+
-- in Waste to be destroyed.
4851

4952
procedure Enqueue
5053
(Self : in out Job_Scheduler'Class;
5154
Job : not null LSP.Server_Jobs.Server_Job_Access);
5255
-- Put Job into the job queue.
5356

5457
procedure Process_High_Priority_Job
55-
(Self : in out Job_Scheduler'Class;
56-
Client :
58+
(Self : in out Job_Scheduler'Class;
59+
Client :
5760
in out LSP.Client_Message_Receivers.Client_Message_Receiver'Class;
58-
Waste : out LSP.Server_Messages.Server_Message_Access);
61+
Waste : out LSP.Server_Messages.Server_Message_Access);
5962
-- Execute jobs with highest priority (Immediate, Fence).
6063
-- When a job is done the routine returns (in Waste) the message to be
6164
-- deallocated by the server. The Client is used to send messages during
6265
-- the execution of the job.
6366

6467
procedure Process_Job
65-
(Self : in out Job_Scheduler'Class;
66-
Client :
68+
(Self : in out Job_Scheduler'Class;
69+
Client :
6770
in out LSP.Client_Message_Receivers.Client_Message_Receiver'Class;
68-
Waste : out LSP.Server_Messages.Server_Message_Access);
69-
-- Execute jobs with ordinal priority (Low, High).
71+
Waste : out LSP.Server_Messages.Server_Message_Access);
72+
-- Execute (already created) jobs with ordinal priority (Low, High).
7073
-- When a job is done the routine returns (in Waste) the message to be
7174
-- deallocated by the server. The Client is used to send messages during
7275
-- the execution of the job.

source/server/lsp-servers.adb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,14 @@ package body LSP.Servers is
821821
procedure Process_Message (Message : in out Server_Message_Access);
822822
-- Create a job for the message and execute all highest priority jobs
823823

824-
procedure Execute_Jobs (Message : in out Server_Message_Access);
824+
procedure Execute_Jobs (Message : out Server_Message_Access);
825825
-- Execute low priority jobs (if any) till a new message arrive
826826

827827
------------------
828828
-- Execute_Jobs --
829829
------------------
830830

831-
procedure Execute_Jobs (Message : in out Server_Message_Access) is
831+
procedure Execute_Jobs (Message : out Server_Message_Access) is
832832
begin
833833
loop
834834
select
@@ -860,24 +860,25 @@ package body LSP.Servers is
860860
---------------------
861861

862862
procedure Process_Message (Message : in out Server_Message_Access) is
863+
Waste : Server_Message_Access;
863864
begin
864-
Server.Scheduler.Create_Job (Message);
865+
Server.Scheduler.Create_Job (Message, Waste);
866+
867+
if Waste.Assigned then
868+
Server.Destroy_Queue.Enqueue (Waste);
869+
end if;
865870

866871
if Message.Assigned then
867872
-- Scheduler wasn't able to process message, destroy it
868873
Server.Destroy_Queue.Enqueue (Message);
869874
end if;
870875

871876
loop
872-
declare
873-
Waste : Server_Message_Access;
874-
begin
875-
Server.Scheduler.Process_High_Priority_Job (Server.all, Waste);
877+
Server.Scheduler.Process_High_Priority_Job (Server.all, Waste);
876878

877-
exit when not Waste.Assigned;
879+
exit when not Waste.Assigned;
878880

879-
Server.Destroy_Queue.Enqueue (Waste);
880-
end;
881+
Server.Destroy_Queue.Enqueue (Waste);
881882
end loop;
882883

883884
exception

0 commit comments

Comments
 (0)