aboutsummaryrefslogtreecommitdiff
path: root/lib/Utils/src
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-01-21 21:43:21 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2023-01-21 21:43:21 -0500
commit05ebe3b38342ba38ad0f1c418058d5100ca776ab (patch)
tree42d8b368c7dabc09d8761f3cce7411c8f5b0565f /lib/Utils/src
parent46caaac9debdaad496c07af9d3806e67a447066c (diff)
Fix FBM session cancel, fix plugin log file names
Diffstat (limited to 'lib/Utils/src')
-rw-r--r--lib/Utils/src/ERRNO.cs25
-rw-r--r--lib/Utils/src/Memory/MemoryUtil.cs9
-rw-r--r--lib/Utils/src/VNLib.Utils.csproj1
3 files changed, 30 insertions, 5 deletions
diff --git a/lib/Utils/src/ERRNO.cs b/lib/Utils/src/ERRNO.cs
index 972aa49..03ebd17 100644
--- a/lib/Utils/src/ERRNO.cs
+++ b/lib/Utils/src/ERRNO.cs
@@ -124,14 +124,36 @@ namespace VNLib.Utils
public readonly override int GetHashCode() => ErrorCode.GetHashCode();
/// <summary>
+ /// Attempts to parse the value of the character sequence as a new error code
+ /// </summary>
+ /// <param name="value">The character sequence value to parse</param>
+ /// <param name="result">The value </param>
+ /// <returns>True if the value was successfully parsed, false othwerwise</returns>
+ public static bool TryParse(ReadOnlySpan<char> value, out ERRNO result)
+ {
+ result = 0;
+ if (nint.TryParse(value, out nint res))
+ {
+ result = new ERRNO(res);
+ return true;
+ }
+ return false;
+ }
+
+ /// <summary>
/// The integer error value of the current instance in radix 10
/// </summary>
- /// <returns></returns>
+ /// <returns>The radix 10 formatted error code</returns>
public readonly override string ToString()
{
//Return the string of the error code number
return ErrorCode.ToString();
}
+ /// <summary>
+ /// Formats the internal nint error code as a string in specified format
+ /// </summary>
+ /// <param name="format">The format to use</param>
+ /// <returns>The formatted error code</returns>
public readonly string ToString(string format)
{
//Return the string of the error code number
@@ -143,6 +165,7 @@ namespace VNLib.Utils
{
return ErrorCode.TryFormat(destination, out charsWritten, format, provider);
}
+
///<inheritdoc/>
public readonly string ToString(string format, IFormatProvider formatProvider)
{
diff --git a/lib/Utils/src/Memory/MemoryUtil.cs b/lib/Utils/src/Memory/MemoryUtil.cs
index c20d956..56ccb7e 100644
--- a/lib/Utils/src/Memory/MemoryUtil.cs
+++ b/lib/Utils/src/Memory/MemoryUtil.cs
@@ -88,11 +88,11 @@ namespace VNLib.Utils.Memory
private static Lazy<IUnmangedHeap> InitHeapInternal()
{
//Get env for heap diag
- bool enableDiag = Environment.GetEnvironmentVariable(SHARED_HEAP_ENABLE_DIAGNOISTICS_ENV) == "1";
-
- Trace.WriteIf(enableDiag, "Shared heap diagnostics enabled");
+ _ = ERRNO.TryParse(Environment.GetEnvironmentVariable(SHARED_HEAP_ENABLE_DIAGNOISTICS_ENV), out ERRNO diagEnable);
+
+ Trace.WriteIf(diagEnable, "Shared heap diagnostics enabled");
- Lazy<IUnmangedHeap> heap = new (() => InitHeapInternal(true, enableDiag), LazyThreadSafetyMode.PublicationOnly);
+ Lazy<IUnmangedHeap> heap = new (() => InitHeapInternal(true, diagEnable), LazyThreadSafetyMode.PublicationOnly);
//Cleanup the heap on process exit
AppDomain.CurrentDomain.DomainUnload += DomainUnloaded;
@@ -505,6 +505,7 @@ namespace VNLib.Utils.Memory
/// <exception cref="OverflowException"></exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static nuint ByteCount<T>(nuint elementCount) => checked(elementCount * (nuint)Unsafe.SizeOf<T>());
+
/// <summary>
/// Gets the byte multiple of the length parameter
/// </summary>
diff --git a/lib/Utils/src/VNLib.Utils.csproj b/lib/Utils/src/VNLib.Utils.csproj
index b14ab27..d326325 100644
--- a/lib/Utils/src/VNLib.Utils.csproj
+++ b/lib/Utils/src/VNLib.Utils.csproj
@@ -16,6 +16,7 @@
<AnalysisLevel>latest-all</AnalysisLevel>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>\\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk</AssemblyOriginatorKeyFile>
+ <RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup>
<ItemGroup>