< Summary

Information
Class: GridForge.RuntimeIdentityAllocator
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Support/RuntimeIdentityAllocator.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 28
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Allocate(...)100%66100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Support/RuntimeIdentityAllocator.cs

#LineLine coverage
 1//=======================================================================
 2// RuntimeIdentityAllocator.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9using System.Threading;
 10
 11namespace GridForge;
 12
 13internal static class RuntimeIdentityAllocator
 14{
 15    internal static long Allocate(ref long counter)
 16    {
 17        while (true)
 18        {
 227719            long current = Volatile.Read(ref counter);
 227720            if (current < 0 || current == long.MaxValue)
 321                throw new InvalidOperationException("Runtime identity allocator exhausted.");
 22
 227423            long next = current + 1;
 227424            if (Interlocked.CompareExchange(ref counter, next, current) == current)
 227325                return next;
 26        }
 27    }
 28}

Methods/Properties

Allocate(System.Int64&)