daily update on 20240501 by nitload youmu, tracking blueprint corupt[D[D[Dr
This commit is contained in:
@@ -36,8 +36,6 @@ using System.Threading;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public delegate void TimeSpanRefeshCallback();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A microsecond-accuracy timer. It will refresh every a certain time span.
|
||||
@@ -48,7 +46,7 @@ namespace StgSharp
|
||||
private Action<SemaphoreFullException> _frameUpdateMissCallback = null;
|
||||
|
||||
private readonly int _maxSpanCount;
|
||||
private TimeSpanRefeshCallback _refeshCallback;
|
||||
private Action _refreshCallback;
|
||||
private SemaphoreSlim _refreshSemaphore = new SemaphoreSlim(0, 1);
|
||||
private long _spanBegin;
|
||||
private readonly long _spanLength;
|
||||
@@ -58,37 +56,38 @@ namespace StgSharp
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TimeSpanProvider"/> and define the length of time span. Length of a single time span is defined in microseconds.
|
||||
/// </summary>
|
||||
/// <param name="spanLength"></param>
|
||||
/// <param name="spanMicroSeconds"></param>
|
||||
/// <param name="provider"></param>
|
||||
public TimeSpanProvider(long spanLength, TimeSourceProviderBase provider)
|
||||
public TimeSpanProvider(long spanMicroSeconds, TimeSourceProviderBase provider)
|
||||
{
|
||||
_spanLength = spanLength;
|
||||
_spanLength = spanMicroSeconds;
|
||||
_maxSpanCount = int.MaxValue;
|
||||
provider.AddSubscriber(this);
|
||||
_subscribed = true;
|
||||
_refeshCallback = () => { };
|
||||
_refreshCallback = new Action(() => { });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TimeSpanProvider"/> and define the length of time span.
|
||||
/// Length of a single time span is defined in seconds.
|
||||
/// </summary>
|
||||
/// <param name="spanLength"></param>
|
||||
/// <param name="spanSeconds"></param>
|
||||
/// <param name="provider"></param>
|
||||
public TimeSpanProvider(double spanLength, TimeSourceProviderBase provider)
|
||||
public TimeSpanProvider(double spanSeconds, TimeSourceProviderBase provider)
|
||||
{
|
||||
_spanLength = (long)(spanLength * 1000L * 1000L);
|
||||
_spanLength = (long)(spanSeconds * 1000L * 1000L);
|
||||
_spanBegin = -_spanLength;
|
||||
_maxSpanCount = int.MaxValue;
|
||||
provider.AddSubscriber(this);
|
||||
_subscribed = true;
|
||||
_refeshCallback = () => { };
|
||||
_refreshCallback = new Action(() => { });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TimeSpanProvider"/> and define the length of time span. Length of a single time span is defined in microseconds.
|
||||
/// </summary>
|
||||
/// <param name="spanLength"></param>
|
||||
/// <param name="maxSpan"></param>
|
||||
/// <param name="provider"></param>
|
||||
public TimeSpanProvider(long spanLength, int maxSpan, TimeSourceProviderBase provider)
|
||||
{
|
||||
@@ -118,10 +117,10 @@ namespace StgSharp
|
||||
/// <summary>
|
||||
/// The method this <see cref="TimeSpanProvider"/> will call every time a new time span started.
|
||||
/// </summary>
|
||||
public TimeSpanRefeshCallback SpanRefreshCallback
|
||||
public Action SpanRefreshCallback
|
||||
{
|
||||
get => _refeshCallback;
|
||||
set => _refeshCallback = value;
|
||||
get => _refreshCallback;
|
||||
set => _refreshCallback = value;
|
||||
}
|
||||
|
||||
public void SubscribeToTimeSource(TimeSourceProviderBase serviceHandler)
|
||||
@@ -147,7 +146,10 @@ namespace StgSharp
|
||||
timeSpanCount++;
|
||||
try
|
||||
{
|
||||
_refeshCallback();
|
||||
if (_refreshCallback != null)
|
||||
{
|
||||
_refreshCallback();
|
||||
}
|
||||
_refreshSemaphore.Release();
|
||||
}
|
||||
catch (SemaphoreFullException ex)
|
||||
|
||||
Reference in New Issue
Block a user