| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationFlowBatchWork.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 | | |
| | | 8 | | using System; |
| | | 9 | | |
| | | 10 | | namespace Trailblazer.Pathing; |
| | | 11 | | |
| | | 12 | | /// <summary>Coordinates one deterministically admitted flow query batch.</summary> |
| | | 13 | | internal readonly struct NavigationFlowBatchWork : IDisposable |
| | | 14 | | { |
| | | 15 | | private readonly NavigationFlowAdmissionGate? _owner; |
| | | 16 | | |
| | | 17 | | internal NavigationFlowBatchWork( |
| | | 18 | | NavigationFlowAdmissionGate owner, |
| | | 19 | | ulong generation) |
| | | 20 | | { |
| | 57 | 21 | | _owner = owner; |
| | 57 | 22 | | Generation = generation; |
| | 57 | 23 | | } |
| | | 24 | | |
| | | 25 | | internal ulong Generation { get; } |
| | | 26 | | |
| | 6 | 27 | | internal int AdmittedCount => Owner.GetAdmittedCount(this); |
| | | 28 | | |
| | 140 | 29 | | internal bool IsAdmissionComplete => Owner.IsAdmissionComplete(this); |
| | | 30 | | |
| | | 31 | | internal NavigationFlowQueryStatus GetStatus(int inputIndex) => |
| | 62 | 32 | | Owner.GetStatus(this, inputIndex); |
| | | 33 | | |
| | | 34 | | internal bool IsReadyToPublish(int inputIndex) => |
| | 87 | 35 | | Owner.IsReadyToPublish(this, inputIndex); |
| | | 36 | | |
| | | 37 | | internal void AdvanceAdmission(int lookupStepLimit, int endpointCandidateStepLimit) => |
| | 85 | 38 | | Owner.AdvanceAdmission(this, lookupStepLimit, endpointCandidateStepLimit); |
| | | 39 | | |
| | | 40 | | internal NavigationFlowQueryStatus AdvanceSearch( |
| | | 41 | | int inputIndex, |
| | | 42 | | int lookupStepLimit, |
| | | 43 | | int nodeStepLimit, |
| | | 44 | | int edgeStepLimit, |
| | 40 | 45 | | int connectionStepLimit) => Owner.AdvanceSearch( |
| | 40 | 46 | | this, |
| | 40 | 47 | | inputIndex, |
| | 40 | 48 | | lookupStepLimit, |
| | 40 | 49 | | nodeStepLimit, |
| | 40 | 50 | | edgeStepLimit, |
| | 40 | 51 | | connectionStepLimit); |
| | | 52 | | |
| | | 53 | | internal int PublishReadyPrefix(int maximumCount) => |
| | 49 | 54 | | Owner.PublishReadyPrefix(this, maximumCount); |
| | | 55 | | |
| | | 56 | | internal NavigationFlowQueryResult TakeResult(int inputIndex) => |
| | 37 | 57 | | Owner.TakeResult(this, inputIndex); |
| | | 58 | | |
| | 1075 | 59 | | public void Dispose() => _owner?.Release(this); |
| | | 60 | | |
| | | 61 | | internal bool IsOwnedBy(NavigationFlowAdmissionGate owner) => |
| | 559 | 62 | | ReferenceEquals(_owner, owner); |
| | | 63 | | |
| | | 64 | | private NavigationFlowAdmissionGate Owner => |
| | 506 | 65 | | _owner ?? throw new ObjectDisposedException(nameof(NavigationFlowBatchWork)); |
| | | 66 | | } |