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:
Nitload
2025-06-18 05:17:14 +08:00
parent 74c01effe4
commit c624a8ca38
300 changed files with 12227 additions and 4303 deletions
+40 -36
View File
@@ -38,12 +38,13 @@ using System.Threading.Tasks;
namespace StgSharp.Threading
{
public class CancellableTask:IDisposable
public class CancellableTask : IDisposable
{
private bool disposedValue;
private CancellationTokenSource cts;
private protected Action<CancellationToken> _startup;
private protected Task _internalTask;
private CancellationTokenSource cts;
private bool disposedValue;
private protected CancellableTask()
{
@@ -82,9 +83,23 @@ namespace StgSharp.Threading
_internalTask.Wait();
}
// ~CancellableTask()
// {
// Dispose(disposing: false);
// }
public void Dispose()
{
Dispose( disposing: true );
GC.SuppressFinalize( this );
}
public static CancellableTask Run( Action<CancellationToken> startup )
{
CancellableTask ret = new CancellableTask { _startup = startup };
CancellableTask ret = new CancellableTask
{
_startup = startup
};
ret._internalTask = Task.Run( ret.InternalAction );
return ret;
}
@@ -104,10 +119,30 @@ namespace StgSharp.Threading
[MethodImpl( MethodImplOptions.AggressiveInlining )]
internal void InternalAction()
{
//Console.WriteLine($"Task {Task.CurrentId} is running.");
_startup( Cts.Token );
}
protected virtual void Dispose( bool disposing )
{
if( !disposedValue )
{
if( disposing )
{
if( IsCompleted )
{
cts.Dispose();
_internalTask.Dispose();
} else
{
throw new InvalidOperationException(
"Cannot dispose a cancellable task before completed" );
}
}
disposedValue = true;
}
}
public static implicit operator Task( CancellableTask task )
{
return task._internalTask;
@@ -118,36 +153,5 @@ namespace StgSharp.Threading
Cts.Dispose();
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
if (IsCompleted)
{
cts.Dispose();
_internalTask.Dispose();
}
else
{
throw new InvalidOperationException("Cannot dispose a cancellable task before completed");
}
}
disposedValue = true;
}
}
// ~CancellableTask()
// {
// Dispose(disposing: false);
// }
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}
+3 -4
View File
@@ -41,8 +41,7 @@ namespace StgSharp.Threading
public static partial class ThreadHelper
{
private static readonly Thread _emptyThreadCache = new Thread(
() => { } );
private static readonly Thread _emptyThreadCache = new Thread( () => { } );
static ThreadHelper()
{
@@ -50,8 +49,8 @@ namespace StgSharp.Threading
}
/// <summary>
/// An individual thread doing nothing, and its <see cref="Thread.IsAlive" /> <see
/// langword="property" /> always returns false.
/// An individual thread doing nothing, and its <see cref="Thread.IsAlive" /> <see
/// langword="property" /> always returns false.
/// </summary>
public static Thread EmptyThread
{