diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-08-31 16:56:29 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-08-31 16:56:29 -0500 |
| commit | bcc489ef42b9a17a3c2d6b52abe98792d9d39558 (patch) | |
| tree | ef05c71b2e020498a751be15d9cdff83f1b26d78 | |
| parent | 97d1aa0bf26ed58a095420437595bdee7ea40f4c (diff) | |
| download | slskd-bcc489ef42b9a17a3c2d6b52abe98792d9d39558.tar.gz | |
expose GlobalSlots
| -rw-r--r-- | src/slskd/Transfers/Uploads/UploadQueue.cs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/slskd/Transfers/Uploads/UploadQueue.cs b/src/slskd/Transfers/Uploads/UploadQueue.cs index 36e5474c..0ab10a7e 100644 --- a/src/slskd/Transfers/Uploads/UploadQueue.cs +++ b/src/slskd/Transfers/Uploads/UploadQueue.cs @@ -35,6 +35,11 @@ namespace slskd.Transfers public interface IUploadQueue { /// <summary> + /// Gets the global upload slot limit. + /// </summary> + int GlobalSlots { get; } + + /// <summary> /// Awaits the start of an upload. /// </summary> /// <param name="username">The username of the remote user.</param> @@ -105,11 +110,15 @@ namespace slskd.Transfers Configure(OptionsMonitor.CurrentValue); } + /// <summary> + /// Gets the global upload slot limit. + /// </summary> + public int GlobalSlots { get; private set; } = 0; + private Dictionary<string, UploadGroup> Groups { get; set; } = new Dictionary<string, UploadGroup>(); private int LastGlobalSlots { get; set; } private string LastOptionsHash { get; set; } private ILogger Log { get; } = Serilog.Log.ForContext<UploadQueue>(); - private int MaxSlots { get; set; } = 0; private IOptionsMonitor<Options> OptionsMonitor { get; } private SemaphoreSlim SyncRoot { get; } = new SemaphoreSlim(1, 1); private ConcurrentDictionary<string, List<Upload>> Uploads { get; set; } = new ConcurrentDictionary<string, List<Upload>>(); @@ -378,7 +387,7 @@ namespace slskd.Transfers return; } - MaxSlots = options.Global.Upload.Slots; + GlobalSlots = options.Global.Upload.Slots; // statically add built-in groups var groups = new List<UploadGroup>() @@ -392,7 +401,7 @@ namespace slskd.Transfers { Name = Application.PrivilegedGroup, Priority = 0, - Slots = MaxSlots, + Slots = GlobalSlots, UsedSlots = GetExistingUsedSlotsOrDefault(Application.PrivilegedGroup), Strategy = QueueStrategy.FirstInFirstOut, }, @@ -442,7 +451,7 @@ namespace slskd.Transfers try { - if (Groups.Values.Sum(g => g.UsedSlots) >= MaxSlots) + if (Groups.Values.Sum(g => g.UsedSlots) >= GlobalSlots) { return null; } |
