< Summary

Information
Class: Trailblazer.Pathing.NavigationAStarPayloadLease
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/AStar/NavigationAStarPayloadLease.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 38
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Payload()100%44100%
Bind(...)100%11100%
DetachEntry()100%11100%
Dispose()100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/AStar/NavigationAStarPayloadLease.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationAStarPayloadLease.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 Trailblazer.Pathing;
 12
 13/// <summary>Owns one active reference to an immutable A* payload.</summary>
 14internal sealed class NavigationAStarPayloadLease : IDisposable
 15{
 16    private readonly NavigationAStarPayloadCache _owner;
 17    private NavigationAStarPayloadCache.CacheEntry? _entry;
 18
 11019    internal NavigationAStarPayloadLease(NavigationAStarPayloadCache owner)
 20    {
 11021        _owner = owner;
 11022    }
 23
 659424    internal NavigationAStarPayload Payload => _entry?.Payload
 659425        ?? throw new ObjectDisposedException(nameof(NavigationAStarPayloadLease));
 26
 27    internal NavigationAStarPayloadLease? NextPooled { get; set; }
 28
 29    internal void Bind(NavigationAStarPayloadCache.CacheEntry entry)
 30    {
 109331        _entry = entry;
 109332    }
 33
 34    internal NavigationAStarPayloadCache.CacheEntry? DetachEntry() =>
 107435        Interlocked.Exchange(ref _entry, null);
 36
 107437    public void Dispose() => _owner.Return(this);
 38}