diff --git a/source/ada/lsp-ada_indexing.ads b/source/ada/lsp-ada_indexing.ads index eb487be09..c04acc081 100644 --- a/source/ada/lsp-ada_indexing.ads +++ b/source/ada/lsp-ada_indexing.ads @@ -86,7 +86,7 @@ private overriding function Priority (Self : Indexing_Job) return LSP.Server_Jobs.Job_Priority is - (LSP.Server_Jobs.Low); + (LSP.Server_Jobs.Lowest); overriding procedure Execute (Self : in out Indexing_Job; diff --git a/source/server/lsp-job_schedulers.adb b/source/server/lsp-job_schedulers.adb index 9591ab739..484562665 100644 --- a/source/server/lsp-job_schedulers.adb +++ b/source/server/lsp-job_schedulers.adb @@ -132,9 +132,11 @@ package body LSP.Job_Schedulers is end if; if Job.Priority = Fence then - -- Process other jobs before any Fence job - while (for some List of Self.Jobs => not List.Is_Empty) loop - Self.Process_Job (Client, Waste); + -- Process other jobs (excluding indexing) before any Fence job + while + (for some List of Self.Jobs (Low .. High) => not List.Is_Empty) + loop + Self.Process_Job (Client, Waste, From => Low); if Waste.Assigned then return; @@ -163,14 +165,17 @@ package body LSP.Job_Schedulers is (Self : in out Job_Scheduler'Class; Client : in out LSP.Client_Message_Receivers.Client_Message_Receiver'Class; - Waste : out LSP.Server_Messages.Server_Message_Access) + Waste : out LSP.Server_Messages.Server_Message_Access; + From : LSP.Server_Jobs.Job_Priority := LSP.Server_Jobs.Lowest) is Status : LSP.Server_Jobs.Execution_Status; begin Self.Complete_Last_Fence_Job (null, Waste); if not Waste.Assigned then - for List of reverse Self.Jobs when not List.Is_Empty loop + for List of reverse Self.Jobs (From .. LSP.Server_Jobs.High) + when not List.Is_Empty + loop declare Job : LSP.Server_Jobs.Server_Job_Access := List.First_Element; begin diff --git a/source/server/lsp-job_schedulers.ads b/source/server/lsp-job_schedulers.ads index b51d44487..53feb9e16 100644 --- a/source/server/lsp-job_schedulers.ads +++ b/source/server/lsp-job_schedulers.ads @@ -68,8 +68,9 @@ package LSP.Job_Schedulers is (Self : in out Job_Scheduler'Class; Client : in out LSP.Client_Message_Receivers.Client_Message_Receiver'Class; - Waste : out LSP.Server_Messages.Server_Message_Access); - -- Execute (already created) jobs with ordinal priority (Low, High). + Waste : out LSP.Server_Messages.Server_Message_Access; + From : LSP.Server_Jobs.Job_Priority := LSP.Server_Jobs.Lowest); + -- Execute (already created) jobs with ordinal priority (From .. High). -- When a job is done the routine returns (in Waste) the message to be -- deallocated by the server. The Client is used to send messages during -- the execution of the job. @@ -88,8 +89,7 @@ private package Job_Lists is new Ada.Containers.Doubly_Linked_Lists (LSP.Server_Jobs.Server_Job_Access, LSP.Server_Jobs."="); - subtype Ordinal_Priority is LSP.Server_Jobs.Job_Priority - range LSP.Server_Jobs.Low .. LSP.Server_Jobs.High; + subtype Ordinal_Priority is LSP.Server_Jobs.Ordinal_Priority; type Job_List_Array is array (Ordinal_Priority) of Job_Lists.List; diff --git a/source/server/lsp-server_jobs.ads b/source/server/lsp-server_jobs.ads index 9a6f9c59e..83895df7e 100644 --- a/source/server/lsp-server_jobs.ads +++ b/source/server/lsp-server_jobs.ads @@ -21,9 +21,10 @@ with LSP.Server_Messages; package LSP.Server_Jobs is pragma Preelaborate; - type Job_Priority is (Low, High, Immediate, Fence); + type Job_Priority is (Lowest, Low, High, Immediate, Fence); -- Job priority to schedule jobs. -- + -- @value Lowest - indexing jobs -- @value Low - long running jobs like find-all-references -- @value High - fast queries like hover -- @value Immediate - urgent queries like cancel-request @@ -33,7 +34,7 @@ package LSP.Server_Jobs is -- new messages until the job is done. Server execute each job in its -- queue before executing any Fence job. - subtype Ordinal_Priority is Job_Priority range Low .. High; + subtype Ordinal_Priority is Job_Priority range Lowest .. High; type Server_Job is limited interface; diff --git a/source/server/lsp-servers.adb b/source/server/lsp-servers.adb index 610ceee19..a7d6db935 100644 --- a/source/server/lsp-servers.adb +++ b/source/server/lsp-servers.adb @@ -853,6 +853,10 @@ package body LSP.Servers is end; end select; end loop; + exception + when E : others => + -- Message handler should never raise any exception + Server.Tracer.Trace_Exception (E, "Execute_Jobs raised error!"); end Execute_Jobs; --------------------- @@ -884,7 +888,7 @@ package body LSP.Servers is exception when E : others => -- Message handler should never raise any exception - Server.Tracer.Trace_Exception (E, "Message handler raised error!"); + Server.Tracer.Trace_Exception (E, "Process_Message raised error!"); end Process_Message; Request : Server_Message_Access;