[fix time]time service now stopps properly

This commit is contained in:
Youmu Liu
2025-12-09 09:33:11 +08:00
parent f960982bd3
commit 6acc8629b8
5 changed files with 16 additions and 19 deletions
@@ -177,7 +177,11 @@ namespace StgSharp.Mathematics.Graphic
InternalYaw(); InternalYaw();
} }
public void SetViewRange(Radius fovRadius, Vec2 size, Vec2 offset, (float front, float back) depthRange) public void SetViewRange(
Radius fovRadius,
Vec2 size,
Vec2 offset,
(float front, float back) depthRange)
{ {
float float
distance = _target.GetLength(), distance = _target.GetLength(),
+1 -1
View File
@@ -119,7 +119,7 @@ namespace StgSharp
{ {
if (!_subscribers[i].OnSpanTick(elapsedTicks)) if (!_subscribers[i].OnSpanTick(elapsedTicks))
{ {
Console.WriteLine("removed"); // Console.WriteLine("removed");
_subscribers.RemoveAt(i); _subscribers.RemoveAt(i);
i--; // adjust index after removal i--; // adjust index after removal
} }
+1 -9
View File
@@ -146,15 +146,7 @@ namespace StgSharp.Common.Timing
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool EndsAt(long currentTick) public override bool EndsAt(long currentTick) => currentTick >= EndingTick;
{
if (currentTick >= EndingTick)
{
Console.WriteLine("Ended");
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool IsNextFrameReady(long currentTick) public override bool IsNextFrameReady(long currentTick)
@@ -88,7 +88,7 @@ namespace StgSharp.Timing
// mark provider as ended so external users can observe terminal state // mark provider as ended so external users can observe terminal state
Volatile.Write(ref _endedFlag, 1); Volatile.Write(ref _endedFlag, 1);
s_unusedID.Push(TokenID); s_unusedID.Push(TokenID);
_event.Dispose(); _event.Set();
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
@@ -111,7 +111,9 @@ namespace StgSharp.Timing
while (true) while (true)
{ {
int cur = Volatile.Read(ref _pendingSpans); int cur = Volatile.Read(ref _pendingSpans);
if (cur == 0) { if (cur == 0)
{
_event.Dispose();
return; return;
} }
@@ -207,7 +209,8 @@ namespace StgSharp.Timing
{ {
// mark ended due to sequence timeout, then dispose // mark ended due to sequence timeout, then dispose
Volatile.Write(ref _endedFlag, 1); Volatile.Write(ref _endedFlag, 1);
Console.WriteLine("Time span ended.");
// Console.WriteLine("Time span ended.");
Dispose(); Dispose();
return false; return false;
} }
+3 -5
View File
@@ -92,12 +92,10 @@ namespace StgSharp
// Configure a simple sequence: // Configure a simple sequence:
// initial slice = 0.5s, total = 5s, growth multiplier = 2, min slice = 0.75s // initial slice = 0.5s, total = 5s, growth multiplier = 2, min slice = 0.75s
TimeSequence seq = TimeSequence seq =
/*
TimeSequence.CreateLogarithmic(initialSliceSeconds:0.5,
totalSeconds:5.0,
growthMultiplier:2.0,
minSliceSeconds:0.75);
/**/ /**/
TimeSequence.CreateLogarithmic(initialSliceSeconds:0.5, totalSeconds:5.0,
growthMultiplier:2.0, minSliceSeconds:0.75);
/*
TimeSequence.CreateLinear(5, 1); TimeSequence.CreateLinear(5, 1);
/**/ /**/