Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="TimeSpanProvider.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -40,7 +39,7 @@ using System.Threading;
|
||||
namespace StgSharp.Timing
|
||||
{
|
||||
/// <summary>
|
||||
/// A microsecond-accuracy timer. It will refresh every a certain time span.
|
||||
/// A microsecond-accuracy timer. It will refresh every a certain time span.
|
||||
/// </summary>
|
||||
public class TimeSpanProvider
|
||||
{
|
||||
@@ -58,18 +57,18 @@ namespace StgSharp.Timing
|
||||
private readonly TimeSourceProviderBase _timeSource;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TimeSpanProvider" /> and define the length of time span. Length
|
||||
/// of a single time span is defined in microseconds.
|
||||
/// 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="spanMicroSeconds"></param>
|
||||
/// <param _name="provider"></param>
|
||||
public TimeSpanProvider(
|
||||
long spanMicroSeconds,
|
||||
TimeSourceProviderBase provider )
|
||||
/// <param _label="spanMicroSeconds">
|
||||
///
|
||||
/// </param>
|
||||
/// <param _label="provider">
|
||||
///
|
||||
/// </param>
|
||||
public TimeSpanProvider( long spanMicroSeconds, TimeSourceProviderBase provider )
|
||||
{
|
||||
if( provider == null ) {
|
||||
throw new ArgumentNullException( nameof( provider ) );
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull( provider );
|
||||
_timeSource = provider;
|
||||
_spanLength = spanMicroSeconds;
|
||||
_maxSpanCount = int.MaxValue;
|
||||
@@ -80,18 +79,18 @@ namespace StgSharp.Timing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TimeSpanProvider" /> and define the length of time span. Length
|
||||
/// of a single time span is defined in seconds.
|
||||
/// 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="spanSeconds"></param>
|
||||
/// <param _name="provider"></param>
|
||||
public TimeSpanProvider(
|
||||
double spanSeconds,
|
||||
TimeSourceProviderBase provider )
|
||||
/// <param _label="spanSeconds">
|
||||
///
|
||||
/// </param>
|
||||
/// <param _label="provider">
|
||||
///
|
||||
/// </param>
|
||||
public TimeSpanProvider( double spanSeconds, TimeSourceProviderBase provider )
|
||||
{
|
||||
if( provider == null ) {
|
||||
throw new ArgumentNullException( nameof( provider ) );
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull( provider );
|
||||
_timeSource = provider;
|
||||
_spanLength = ( long )( spanSeconds * 1000L * 1000L );
|
||||
_spanBegin = -_spanLength;
|
||||
@@ -103,23 +102,23 @@ namespace StgSharp.Timing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TimeSpanProvider" /> and define the length of time span. Length
|
||||
/// of a single time span is defined in microseconds.
|
||||
/// 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,
|
||||
long maxSpan,
|
||||
TimeSourceProviderBase provider )
|
||||
/// <param _label="spanLength">
|
||||
///
|
||||
/// </param>
|
||||
/// <param _label="maxSpan">
|
||||
///
|
||||
/// </param>
|
||||
/// <param _label="provider">
|
||||
///
|
||||
/// </param>
|
||||
public TimeSpanProvider( long spanLength, long maxSpan, TimeSourceProviderBase provider )
|
||||
{
|
||||
if( provider == null ) {
|
||||
throw new ArgumentNullException( nameof( provider ) );
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull( provider );
|
||||
if( maxSpan <= 0 ) {
|
||||
throw new ArgumentException(
|
||||
"Sapn count cannot be smaller than zero" );
|
||||
throw new ArgumentException( "Sapn count cannot be smaller than zero" );
|
||||
}
|
||||
_timeSource = provider;
|
||||
_spanLength = spanLength;
|
||||
@@ -151,14 +150,13 @@ namespace StgSharp.Timing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time source provider provided in <see cref="StgSharp" /> internal framework.
|
||||
/// Time source provider provided in <see cref="World" /> internal framework.
|
||||
/// </summary>
|
||||
public static TimeSourceProviderBase DefaultProvider => StgSharpTime.OnlyInstance;
|
||||
|
||||
public TimeSpanAwaitingToken ParticipantSpanAwaiting( int count )
|
||||
{
|
||||
TimeSpanAwaitingToken token = new TimeSpanAwaitingToken(
|
||||
this, count );
|
||||
TimeSpanAwaitingToken token = new TimeSpanAwaitingToken( this, count );
|
||||
_tokenToAdd.Enqueue( token );
|
||||
return token;
|
||||
}
|
||||
@@ -173,12 +171,9 @@ namespace StgSharp.Timing
|
||||
Interlocked.Exchange( ref _maxSpanCount, 0 );
|
||||
}
|
||||
|
||||
public void SubscribeToTimeSource(
|
||||
TimeSourceProviderBase serviceHandler )
|
||||
public void SubscribeToTimeSource( TimeSourceProviderBase serviceHandler )
|
||||
{
|
||||
if( serviceHandler == null ) {
|
||||
throw new ArgumentNullException( nameof( serviceHandler ) );
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull( serviceHandler );
|
||||
if( _subscribed ) {
|
||||
return;
|
||||
}
|
||||
@@ -196,26 +191,29 @@ namespace StgSharp.Timing
|
||||
if( microseconds - _spanBegin < _spanLength ) {
|
||||
return true;
|
||||
}
|
||||
while( !_tokenToAdd.IsEmpty ) {
|
||||
_tokenToAdd.TryDequeue( out TimeSpanAwaitingToken tokenAdd );
|
||||
foreach( TimeSpanAwaitingToken tokenAdd in _tokenToAdd ) {
|
||||
_awaitingTokens.Add( tokenAdd );
|
||||
}
|
||||
while( !_tokenToQuit.IsEmpty ) {
|
||||
_tokenToQuit.TryDequeue( out TimeSpanAwaitingToken tokenQuit );
|
||||
_tokenToAdd.Clear();
|
||||
foreach( TimeSpanAwaitingToken tokenQuit in _tokenToQuit )
|
||||
{
|
||||
_awaitingTokens.Remove( tokenQuit );
|
||||
InternalIO.InternalWriteLog(
|
||||
$"Awaiting token {tokenQuit!.TokenID} has been removed.",
|
||||
LogType.Info );
|
||||
$"Awaiting token {tokenQuit!.TokenID} has been removed.", LogType.Info );
|
||||
}
|
||||
_tokenToQuit.Clear();
|
||||
|
||||
_spanBegin = microseconds;
|
||||
timeSpanCount++;
|
||||
|
||||
foreach( TimeSpanAwaitingToken item in _awaitingTokens ) {
|
||||
if( item.AwaitingSemaphoreSlim.CurrentCount == 0 ) {
|
||||
foreach( TimeSpanAwaitingToken item in _awaitingTokens )
|
||||
{
|
||||
if( item.AwaitingSemaphoreSlim.CurrentCount == 0 )
|
||||
{
|
||||
item.AwaitingSemaphoreSlim.Release();
|
||||
item.Refresh();
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
item.MissRefresh();
|
||||
}
|
||||
}
|
||||
@@ -223,8 +221,7 @@ namespace StgSharp.Timing
|
||||
return timeSpanCount < _maxSpanCount;
|
||||
}
|
||||
|
||||
public static explicit operator int(
|
||||
[NotNull]TimeSpanProvider provider )
|
||||
public static explicit operator int( [NotNull]TimeSpanProvider provider )
|
||||
{
|
||||
return provider.ToInt32();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user