Skip to content

Commit f5df2f8

Browse files
committed
Make queue consumption truly async
1 parent ea7a0de commit f5df2f8

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/InEngine.Core/InEngine.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFramework>net6.0</TargetFramework>
44
</PropertyGroup>
55
<PropertyGroup>
6-
<Version>4.0.1</Version>
6+
<Version>5.0.0</Version>
77
<FileVersion>5.0.0</FileVersion>
88
<Authors>Ethan Hann</Authors>
99
<Description>Plugin-based queuing and scheduling command server.</Description>

src/InEngine.Core/ServerHost.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading.Tasks;
23
using InEngine.Core.IO;
34
using InEngine.Core.Queuing;
45
using InEngine.Core.Scheduling;
@@ -13,7 +14,7 @@ public class ServerHost : IDisposable, IHasMailSettings, IHasQueueSettings
1314
public QueueSettings QueueSettings { get; set; }
1415
private bool isDisposed;
1516

16-
public void Start()
17+
public async Task StartAsync()
1718
{
1819
SuperScheduler = new SuperScheduler();
1920
SuperScheduler.Initialize(MailSettings);
@@ -24,11 +25,9 @@ public void Start()
2425
};
2526

2627
SuperScheduler.Start();
27-
StartDequeueAsync();
28+
await Dequeue.StartAsync();
2829
}
2930

30-
public async void StartDequeueAsync() => await Dequeue.StartAsync();
31-
3231
public void Dispose()
3332
{
3433
Dispose(true);

src/InEngine/ArgumentInterpreter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Threading.Tasks;
45
using CommandLine;
56
using InEngine.Core;
67
using InEngine.Core.Exceptions;
@@ -21,7 +22,7 @@ public ArgumentInterpreter()
2122
CliLogo = resources.cliLogo;
2223
}
2324

24-
public void Interpret(string[] args)
25+
public async Task Interpret(string[] args)
2526
{
2627
var pluginAssemblies = PluginAssembly.Load<AbstractPlugin>();
2728
var parser = new Parser(with => {
@@ -42,7 +43,7 @@ public void Interpret(string[] args)
4243
{
4344
Write.Info(CliLogo);
4445
Write.Line("Starting...").Newline();
45-
Program.RunServer();
46+
await Program.RunServerAsync();
4647
ExitWithSuccess();
4748
}
4849

src/InEngine/Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Threading.Tasks;
34
using InEngine.Core;
45

56
namespace InEngine;
@@ -8,17 +9,17 @@ public static class Program
89
{
910
public static ServerHost ServerHost { get; set; }
1011

11-
private static void Main(string[] args)
12+
private static async Task Main(string[] args)
1213
{
1314
/*
1415
* Set current working directory as services use the system directory by default.
1516
* Also, allow running the CLI from a different directory than the application root.
1617
*/
1718
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
18-
new ArgumentInterpreter().Interpret(args);
19+
await new ArgumentInterpreter().Interpret(args);
1920
}
2021

21-
public static void RunServer()
22+
public static async Task RunServerAsync()
2223
{
2324
var settings = InEngineSettings.Make();
2425
ServerHost = new ServerHost
@@ -27,7 +28,7 @@ public static void RunServer()
2728
QueueSettings = settings.Queue,
2829
};
2930

30-
ServerHost.Start();
31+
await ServerHost.StartAsync();
3132
Console.WriteLine(resources.foregroundServerInputPrompt);
3233
Console.ReadLine();
3334
ServerHost.Dispose();

0 commit comments

Comments
 (0)