Files
KinginfoGateway/src/Admin/ThingsGateway.NewLife.X/PooledAwait/MethodBuilders/FireAndForgetMethodBuilder.cs
2025-10-18 03:18:45 +08:00

74 lines
2.9 KiB
C#

using PooledAwait.Internal;
using System.ComponentModel;
using System.Runtime.CompilerServices;
#pragma warning disable CS1591
namespace PooledAwait.MethodBuilders
{
/// <summary>
/// This type is not intended for direct usage
/// </summary>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public struct FireAndForgetMethodBuilder
{
public override bool Equals(object? obj) => ThrowHelper.ThrowNotSupportedException<bool>();
public override int GetHashCode() => ThrowHelper.ThrowNotSupportedException<int>();
public override string ToString() => nameof(FireAndForgetMethodBuilder);
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static FireAndForgetMethodBuilder Create() => default;
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetStateMachine(IAsyncStateMachine _) => Counters.SetStateMachine.Increment();
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetResult() { }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetException(Exception exception) => FireAndForget.OnException(exception);
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public FireAndForget Task
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => default;
}
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AwaitOnCompleted<TAwaiter, TStateMachine>(
ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : INotifyCompletion
where TStateMachine : IAsyncStateMachine
=> StateMachineBox<TStateMachine>.AwaitOnCompleted(ref awaiter, ref stateMachine);
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(
ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : ICriticalNotifyCompletion
where TStateMachine : IAsyncStateMachine
=> StateMachineBox<TStateMachine>.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine);
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Start<TStateMachine>(ref TStateMachine stateMachine)
where TStateMachine : IAsyncStateMachine => stateMachine.MoveNext();
}
}