< Summary

Information
Class: Trailblazer.Pathing.NavigationWorldGraphLease
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Graph/NavigationWorldGraphLease.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 44
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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_Graph()100%11100%
Reinitialize(...)100%11100%
DetachGraph()100%11100%
Dispose()100%22100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Graph/NavigationWorldGraphLease.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationWorldGraphLease.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 exact immutable graph generation checkout.</summary>
 14internal sealed class NavigationWorldGraphLease : IDisposable
 15{
 16    private NavigationWorldGraphStore? _owner;
 17    private NavigationWorldGraph? _graph;
 18
 119819    internal NavigationWorldGraphLease(
 119820        NavigationWorldGraphStore owner,
 119821        NavigationWorldGraph graph)
 22    {
 119823        _owner = owner;
 119824        _graph = graph;
 119825        graph.Checkout();
 119826    }
 27
 5281128    internal NavigationWorldGraph Graph => Volatile.Read(ref _graph)!;
 29
 30    internal void Reinitialize(NavigationWorldGraphStore owner, NavigationWorldGraph graph)
 31    {
 822332        _graph = graph;
 822333        Volatile.Write(ref _owner, owner);
 822334        graph.Checkout();
 822335    }
 36
 942037    internal NavigationWorldGraph DetachGraph() => Interlocked.Exchange(ref _graph, null)!;
 38
 39    public void Dispose()
 40    {
 942541        NavigationWorldGraphStore? owner = Interlocked.Exchange(ref _owner, null);
 942542        owner?.Return(this);
 942043    }
 44}