diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-09-24 16:20:21 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-09-24 16:20:21 -0500 |
| commit | c447c545257721398ac0576c07d4873156c5a19e (patch) | |
| tree | caf318e18e851b1796a60affdd371e52e45834cb /src/slskd/Program.cs | |
| parent | 863030b0f43866c88e5fcebf985f7d8ed87f0247 (diff) | |
| download | slskd-c447c545257721398ac0576c07d4873156c5a19e.tar.gz | |
add and use MasterCancellationTokenSource
Diffstat (limited to 'src/slskd/Program.cs')
| -rw-r--r-- | src/slskd/Program.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index e828f242..94624115 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -30,6 +30,7 @@ namespace slskd using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.Json.Serialization; + using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; @@ -189,6 +190,16 @@ namespace slskd /// </summary> public static ConcurrentFixedSizeQueue<LogRecord> LogBuffer { get; } = new ConcurrentFixedSizeQueue<LogRecord>(size: 100); + /// <summary> + /// Gets the master cancellation token source for the program. + /// </summary> + /// <remarks> + /// The token from this source should be used (or linked) to any long-running asynchronous task, so that when the application + /// begins to shut down these tasks also shut down in a timely manner. Actions that control the lifecycle of the program + /// (POSIX signals, a restart from the API, etc) should cancel this source. + /// </remarks> + public static CancellationTokenSource MasterCancellationTokenSource { get; } = new CancellationTokenSource(); + private static IConfigurationRoot Configuration { get; set; } private static OptionsAtStartup OptionsAtStartup { get; } = new OptionsAtStartup(); private static ILogger Log { get; set; } = new ConsoleWriteLineLogger(); |
