aboutsummaryrefslogtreecommitdiff
path: root/lib/Plugins.Essentials
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-01-08 22:04:41 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2024-01-08 22:04:41 -0500
commit50885f7cd7e0519c96b0c95fce9ba6bf69502cf7 (patch)
tree11db78a9c2b9da56de92ebe27183c0ce12098947 /lib/Plugins.Essentials
parent86c0532edc0042b26dda5f1ca41abdf80db46414 (diff)
Some net 8.0 goodies like sha3 support
Diffstat (limited to 'lib/Plugins.Essentials')
-rw-r--r--lib/Plugins.Essentials/src/SemiConsistentVeTable.cs19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/Plugins.Essentials/src/SemiConsistentVeTable.cs b/lib/Plugins.Essentials/src/SemiConsistentVeTable.cs
index 4849107..a235b13 100644
--- a/lib/Plugins.Essentials/src/SemiConsistentVeTable.cs
+++ b/lib/Plugins.Essentials/src/SemiConsistentVeTable.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Plugins.Essentials
@@ -26,6 +26,7 @@ using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using System.Collections.Frozen;
using System.Collections.Generic;
using VNLib.Net.Http;
@@ -60,7 +61,9 @@ namespace VNLib.Plugins.Essentials
/// A "lookup table" that represents virtual endpoints to be processed when an
/// incomming connection matches its path parameter
/// </summary>
- private IReadOnlyDictionary<string, IVirtualEndpoint<HttpEntity>> VirtualEndpoints = new Dictionary<string, IVirtualEndpoint<HttpEntity>>(StringComparer.OrdinalIgnoreCase);
+ private FrozenDictionary<string, IVirtualEndpoint<HttpEntity>> VirtualEndpoints =
+ new Dictionary<string, IVirtualEndpoint<HttpEntity>>(StringComparer.OrdinalIgnoreCase)
+ .ToFrozenDictionary();
/*
@@ -112,15 +115,17 @@ namespace VNLib.Plugins.Essentials
newTable.Add(ep.Path, ep);
}
+ FrozenDictionary<string, IVirtualEndpoint<HttpEntity>> newTableFrozen = newTable.ToFrozenDictionary();
+
//Store the new table
- _ = Interlocked.Exchange(ref VirtualEndpoints, newTable);
+ _ = Interlocked.Exchange(ref VirtualEndpoints, newTableFrozen);
}
}
///<inheritdoc/>
public void RemoveEndpoint(params IEndpoint[] eps)
{
- _ = eps ?? throw new ArgumentNullException(nameof(eps));
+ ArgumentNullException.ThrowIfNull(eps);
//Call remove on path
RemoveEndpoint(eps.Select(static s => s.Path).ToArray());
}
@@ -128,7 +133,7 @@ namespace VNLib.Plugins.Essentials
///<inheritdoc/>
public void RemoveEndpoint(params string[] paths)
{
- _ = paths ?? throw new ArgumentNullException(nameof(paths));
+ ArgumentNullException.ThrowIfNull(paths);
//Make sure all endpoints specify a path
if (paths.Any(static e => string.IsNullOrWhiteSpace(e)))
@@ -152,8 +157,10 @@ namespace VNLib.Plugins.Essentials
_ = newTable.Remove(eps);
}
+ FrozenDictionary<string, IVirtualEndpoint<HttpEntity>> newTableFrozen = newTable.ToFrozenDictionary();
+
//Store the new table
- _ = Interlocked.Exchange(ref VirtualEndpoints, newTable);
+ _ = Interlocked.Exchange(ref VirtualEndpoints, newTableFrozen);
}
}