Skip to content

Commit

Permalink
Fixed constant name
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Jan 29, 2024
1 parent 71d0173 commit f7ff7e9
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/DotNext.Tests/Threading/SchedulerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public static void ScheduleCanceled()
[Fact]
public static void TooLargeTimeout()
{
Throws<ArgumentOutOfRangeException>(static () => Scheduler.ScheduleAsync(static (args, token) => ValueTask.FromResult(args), 42, TimeSpan.FromMilliseconds(Timeout.MaxTimeoutTicks + 1L)));
Throws<ArgumentOutOfRangeException>(static () => Scheduler.ScheduleAsync(static (args, token) => ValueTask.FromResult(args), 42, TimeSpan.FromMilliseconds(Timeout.MaxTimeoutParameterTicks + 1L)));
}
}
2 changes: 1 addition & 1 deletion src/DotNext.Threading/Threading/AsyncCountdownEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ internal ValueTask<bool> SignalAndWaitAsync(out bool completedSynchronously, Tim
{
case Timeout.InfiniteTicks:
goto default;
case < 0L or > Timeout.MaxTimeoutTicks:
case < 0L or > Timeout.MaxTimeoutParameterTicks:
task = ValueTask.FromException<bool>(new ArgumentOutOfRangeException(nameof(timeout)));
break;
case 0L:
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.Threading/Threading/AsyncExchanger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public ValueTask<T> ExchangeAsync(T value, TimeSpan timeout, CancellationToken t
{
case Timeout.InfiniteTicks:
goto default;
case < 0L or > Timeout.MaxTimeoutTicks:
case < 0L or > Timeout.MaxTimeoutParameterTicks:
result = ValueTask.FromException<T>(new ArgumentOutOfRangeException(nameof(timeout)));
break;
case 0L:
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.Threading/Threading/AsyncTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public ValueTask<bool> SignalAndWaitAsync(bool resumeAll, bool throwOnEmptyQueue
{
case Timeout.InfiniteTicks:
goto default;
case < 0L or > Timeout.MaxTimeoutTicks:
case < 0L or > Timeout.MaxTimeoutParameterTicks:
task = ValueTask.FromException<bool>(new ArgumentOutOfRangeException(nameof(timeout)));
break;
case 0L:
Expand Down
8 changes: 4 additions & 4 deletions src/DotNext.Threading/Threading/QueuedSynchronizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private protected ValueTask AcquireAsync<TNode, TLockManager, TOptions>(ref Valu
{
case Timeout.InfiniteTicks:
goto default;
case < 0L or > Timeout.MaxTimeoutTicks:
case < 0L or > Timeout.MaxTimeoutParameterTicks:
task = ValueTask.FromException(new ArgumentOutOfRangeException("timeout"));
break;
case 0L: // attempt to acquire synchronously
Expand Down Expand Up @@ -248,7 +248,7 @@ private protected ValueTask<bool> TryAcquireAsync<TNode, TLockManager, TOptions>
{
case Timeout.InfiniteTicks:
goto default;
case < 0L or > Timeout.MaxTimeoutTicks:
case < 0L or > Timeout.MaxTimeoutParameterTicks:
task = ValueTask.FromException<bool>(new ArgumentOutOfRangeException("timeout"));
break;
case 0L: // attempt to acquire synchronously
Expand Down Expand Up @@ -834,7 +834,7 @@ protected ValueTask<bool> TryAcquireAsync(TContext context, TimeSpan timeout, Ca
{
case Timeout.InfiniteTicks:
goto default;
case < 0L or > Timeout.MaxTimeoutTicks:
case < 0L or > Timeout.MaxTimeoutParameterTicks:
task = ValueTask.FromException<bool>(new ArgumentOutOfRangeException(nameof(timeout)));
break;
case 0L:
Expand Down Expand Up @@ -896,7 +896,7 @@ protected ValueTask AcquireAsync(TContext context, TimeSpan timeout, Cancellatio
{
case Timeout.InfiniteTicks:
goto default;
case < 0L or > Timeout.MaxTimeoutTicks:
case < 0L or > Timeout.MaxTimeoutParameterTicks:
task = ValueTask.FromException(new ArgumentOutOfRangeException(nameof(timeout)));
break;
case 0L:
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.Threading/Threading/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static DelayedTask<TResult> ScheduleAsync<TArgs, TResult>(Func<TArgs, Can

return delay.Ticks switch
{
< 0L and not Timeout.InfiniteTicks or > Timeout.MaxTimeoutTicks => throw new ArgumentOutOfRangeException(nameof(delay)),
< 0L and not Timeout.InfiniteTicks or > Timeout.MaxTimeoutParameterTicks => throw new ArgumentOutOfRangeException(nameof(delay)),
0L => new ImmediateTask<TArgs, TResult>(callback, args, token),
_ => DelayedTaskStateMachine<TArgs, TResult>.Start(callback, args, delay, token),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private protected void OnCompleted(Action<object?> continuation, object? state,

private protected short? Activate(TimeSpan timeout, CancellationToken token)
{
if (timeout.Ticks is < 0L and not Timeout.InfiniteTicks or > Timeout.MaxTimeoutTicks)
if (timeout.Ticks is < 0L and not Timeout.InfiniteTicks or > Timeout.MaxTimeoutParameterTicks)
throw new ArgumentOutOfRangeException(nameof(timeout));

// The task can be created for the completed (but not yet consumed) source.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public ValueTask<bool> WaitToReadAsync(TimeSpan timeout, CancellationToken token
{
case Timeout.InfiniteTicks:
goto default;
case < 0L or > Timeout.MaxTimeoutTicks:
case < 0L or > Timeout.MaxTimeoutParameterTicks:
task = ValueTask.FromException<bool>(new ArgumentOutOfRangeException(nameof(timeout)));
break;
case 0L:
Expand Down
5 changes: 3 additions & 2 deletions src/DotNext/Threading/Timeout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ public readonly struct Timeout
public const long InfiniteTicks = System.Threading.Timeout.Infinite * TimeSpan.TicksPerMillisecond;

/// <summary>
/// Represents maximum possible timeout, in ticks.
/// Represents maximum possible timeout value, in ticks, that can be passed to
/// some methods such as <see cref="Task.Delay(TimeSpan)"/> or <see cref="CancellationTokenSource.CancelAfter(TimeSpan)"/>.
/// </summary>
public const long MaxTimeoutTicks = int.MaxValue * TimeSpan.TicksPerMillisecond;
public const long MaxTimeoutParameterTicks = int.MaxValue * TimeSpan.TicksPerMillisecond;

private readonly Timestamp created; // IsEmpty means infinite timeout
private readonly TimeSpan timeout;
Expand Down

0 comments on commit f7ff7e9

Please sign in to comment.