Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ReactiveUI.Primitives.Async/AsyncContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2026 ReactiveUI Association Incorporated. All rights reserved.
// Copyright (c) 2019-2026 ReactiveUI Association Incorporated. All rights reserved.
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

Expand Down Expand Up @@ -58,7 +58,7 @@ private AsyncContext()
/// Gets a value indicating whether the current context uses the default task scheduler and no synchronization
/// context.
/// </summary>
internal bool IsDefaultContext => SynchronizationContext is null &&
internal bool UsesDefaultSequencer => SynchronizationContext is null &&
Sequencer is null &&
(TaskScheduler is null || TaskScheduler == TaskScheduler.Default);

Expand Down Expand Up @@ -250,7 +250,7 @@ private sealed class ContinuationWorkItem(Action continuation) : IWorkItem
"Performance",
"CA1812:Avoid uninstantiated internal classes",
Justification = "Kept as an internal adapter for generator and test smoke scenarios that need TaskScheduler-shaped sequencer execution.")]
internal sealed class SchedulerTaskScheduler(ISequencer scheduler) : TaskScheduler
internal sealed class SequencerTaskScheduler(ISequencer scheduler) : TaskScheduler
{
/// <summary>
/// Gets the sequencer used by this task-scheduler adapter.
Expand Down
14 changes: 7 additions & 7 deletions src/ReactiveUI.Primitives.Async/Disposables/DisposableAsync.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2026 ReactiveUI Association Incorporated. All rights reserved.
// Copyright (c) 2019-2026 ReactiveUI Association Incorporated. All rights reserved.
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

Expand All @@ -19,7 +19,7 @@ public static class DisposableAsync
/// </summary>
/// <remarks>Use this property when an <see cref="IAsyncDisposable"/> is required but no disposal logic is
/// necessary. This can be useful as a default or placeholder implementation.</remarks>
public static IAsyncDisposable Empty { get; } = new EmptyAsyncDisposable();
public static IAsyncDisposable Empty { get; } = new NoopAsyncDisposable();

/// <summary>
/// Creates a new asynchronous disposable object that invokes the specified delegate when disposed asynchronously.
Expand All @@ -31,7 +31,7 @@ public static IAsyncDisposable Create(Func<ValueTask> disposeAsync)
{
ArgumentExceptionHelper.ThrowIfNull(disposeAsync);

return new AnonymousAsyncDisposable(disposeAsync);
return new DelegateAsyncDisposable(disposeAsync);
}

/// <summary>
Expand All @@ -48,13 +48,13 @@ public static IAsyncDisposable Create<TState>(TState state, Func<TState, ValueTa
{
ArgumentExceptionHelper.ThrowIfNull(disposeAsync);

return new AnonymousAsyncDisposable<TState>(state, disposeAsync);
return new DelegateAsyncDisposable<TState>(state, disposeAsync);
}

/// <summary>
/// An asynchronous disposable that invokes a delegate when disposed.
/// </summary>
internal sealed class AnonymousAsyncDisposable(Func<ValueTask> disposeAsync) : IAsyncDisposable
internal sealed class DelegateAsyncDisposable(Func<ValueTask> disposeAsync) : IAsyncDisposable
{
/// <summary>
/// A flag indicating whether <see cref="DisposeAsync"/> has already been called (0 = not disposed, 1 = disposed).
Expand All @@ -71,7 +71,7 @@ internal sealed class AnonymousAsyncDisposable(Func<ValueTask> disposeAsync) : I
/// name="TState"/>.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the dispose delegate.</typeparam>
internal sealed class AnonymousAsyncDisposable<TState>(TState state, Func<TState, ValueTask> disposeAsync) : IAsyncDisposable
internal sealed class DelegateAsyncDisposable<TState>(TState state, Func<TState, ValueTask> disposeAsync) : IAsyncDisposable
{
/// <summary>
/// A flag indicating whether <see cref="DisposeAsync"/> has already been called (0 = not disposed, 1 = disposed).
Expand All @@ -85,7 +85,7 @@ internal sealed class AnonymousAsyncDisposable<TState>(TState state, Func<TState
/// <summary>
/// An asynchronous disposable that performs no action when disposed.
/// </summary>
internal sealed class EmptyAsyncDisposable : IAsyncDisposable
internal sealed class NoopAsyncDisposable : IAsyncDisposable
{
/// <inheritdoc/>
public ValueTask DisposeAsync() => default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static ValueTask SwapAsync(ref IAsyncDisposable? slot, IAsyncDisposable?
var current = Volatile.Read(ref slot);
while (true)
{
if (ReferenceEquals(current, DisposedSentinel.Instance))
if (ReferenceEquals(current, DisposedSlotMarker.Instance))
{
return value?.DisposeAsync() ?? default;
}
Expand Down Expand Up @@ -64,7 +64,7 @@ public static ValueTask AssignAsync(ref IAsyncDisposable? slot, IAsyncDisposable
return default;
}

if (ReferenceEquals(current, DisposedSentinel.Instance))
if (ReferenceEquals(current, DisposedSlotMarker.Instance))
{
return value?.DisposeAsync() ?? default;
}
Expand All @@ -80,8 +80,8 @@ public static ValueTask AssignAsync(ref IAsyncDisposable? slot, IAsyncDisposable
[DebuggerStepThrough]
public static ValueTask DisposeAsync(ref IAsyncDisposable? slot)
{
var current = Interlocked.Exchange(ref slot, DisposedSentinel.Instance);
if (current is null || ReferenceEquals(current, DisposedSentinel.Instance))
var current = Interlocked.Exchange(ref slot, DisposedSlotMarker.Instance);
if (current is null || ReferenceEquals(current, DisposedSlotMarker.Instance))
{
return default;
}
Expand All @@ -93,15 +93,15 @@ public static ValueTask DisposeAsync(ref IAsyncDisposable? slot)
/// <param name="slot">The slot field to inspect.</param>
/// <returns><see langword="true"/> if the slot currently holds the disposed sentinel.</returns>
public static bool IsDisposed(IAsyncDisposable? slot) =>
ReferenceEquals(slot, DisposedSentinel.Instance);
ReferenceEquals(slot, DisposedSlotMarker.Instance);

/// <summary>Shared sentinel marking a disposed slot. Distinct from the per-class sentinels in
/// <see cref="SingleReplaceableDisposableAsync"/> and <see cref="SingleAssignmentDisposableAsync"/> so the
/// slot helpers can be used independently of (and alongside) those wrapper classes.</summary>
internal sealed class DisposedSentinel : IAsyncDisposable
internal sealed class DisposedSlotMarker : IAsyncDisposable
{
/// <summary>Singleton sentinel instance.</summary>
public static readonly DisposedSentinel Instance = new();
public static readonly DisposedSlotMarker Instance = new();

/// <inheritdoc/>
ValueTask IAsyncDisposable.DisposeAsync() => default;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2026 ReactiveUI Association Incorporated. All rights reserved.
// Copyright (c) 2019-2026 ReactiveUI Association Incorporated. All rights reserved.
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

Expand All @@ -24,7 +24,7 @@ public sealed class SingleAssignmentDisposableAsync : IAsyncDisposable
/// <summary>
/// Gets a value indicating whether the object has been disposed.
/// </summary>
public bool IsDisposed => ReferenceEquals(Volatile.Read(ref _current), DisposedSentinel.Instance);
public bool IsDisposed => ReferenceEquals(Volatile.Read(ref _current), DisposedSlotMarker.Instance);

/// <summary>
/// Gets the current asynchronous disposable resource, or an empty disposable if the resource has already been
Expand All @@ -35,7 +35,7 @@ public sealed class SingleAssignmentDisposableAsync : IAsyncDisposable
public IAsyncDisposable? GetDisposable()
{
var field = Volatile.Read(ref _current);
if (ReferenceEquals(field, DisposedSentinel.Instance))
if (ReferenceEquals(field, DisposedSlotMarker.Instance))
{
return DisposableAsync.Empty;
}
Expand All @@ -50,7 +50,7 @@ public sealed class SingleAssignmentDisposableAsync : IAsyncDisposable
/// <param name="value">The new <see cref="IAsyncDisposable"/> instance to set as the current resource, or <see langword="null"/> to
/// clear the current resource.</param>
/// <returns>A <see cref="ValueTask"/> that represents the asynchronous operation.</returns>
public ValueTask SetDisposableAsync(IAsyncDisposable? value) => SetDisposableAsync(ref _current, value);
public ValueTask SetDisposableAsync(IAsyncDisposable? value) => AssignDisposableAsync(ref _current, value);

/// <summary>
/// Asynchronously releases the unmanaged resources used by the object.
Expand All @@ -69,7 +69,7 @@ public sealed class SingleAssignmentDisposableAsync : IAsyncDisposable
/// <param name="value">The <see cref="IAsyncDisposable"/> instance to assign to the field, or null to leave the field unset.</param>
/// <returns>A <see cref="ValueTask"/> that represents the asynchronous dispose operation if the field was already disposed;
/// otherwise, a default <see cref="ValueTask"/>.</returns>
internal static ValueTask SetDisposableAsync(ref IAsyncDisposable? field, IAsyncDisposable? value)
internal static ValueTask AssignDisposableAsync(ref IAsyncDisposable? field, IAsyncDisposable? value)
{
var current = Interlocked.CompareExchange(ref field, value, null);
if (current == null)
Expand All @@ -78,7 +78,7 @@ internal static ValueTask SetDisposableAsync(ref IAsyncDisposable? field, IAsync
return default;
}

if (ReferenceEquals(current, DisposedSentinel.Instance))
if (ReferenceEquals(current, DisposedSlotMarker.Instance))
{
if (value is not null)
{
Expand All @@ -104,8 +104,8 @@ internal static ValueTask SetDisposableAsync(ref IAsyncDisposable? field, IAsync
[DebuggerStepThrough]
internal static ValueTask DisposeAsync(ref IAsyncDisposable? field)
{
var current = Interlocked.Exchange(ref field, DisposedSentinel.Instance);
if (ReferenceEquals(current, DisposedSentinel.Instance) || current is null)
var current = Interlocked.Exchange(ref field, DisposedSlotMarker.Instance);
if (ReferenceEquals(current, DisposedSlotMarker.Instance) || current is null)
{
return default;
}
Expand All @@ -123,12 +123,12 @@ internal static InvalidOperationException CreateAlreadyAssignedException() =>
/// <summary>
/// A sentinel object used to indicate that the <see cref="SingleAssignmentDisposableAsync"/> has been disposed.
/// </summary>
internal sealed class DisposedSentinel : IAsyncDisposable
internal sealed class DisposedSlotMarker : IAsyncDisposable
{
/// <summary>
/// Gets the singleton instance of <see cref="DisposedSentinel"/>.
/// Gets the singleton instance of <see cref="DisposedSlotMarker"/>.
/// </summary>
public static readonly DisposedSentinel Instance = new();
public static readonly DisposedSlotMarker Instance = new();

/// <inheritdoc/>
ValueTask IAsyncDisposable.DisposeAsync() => default;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2026 ReactiveUI Association Incorporated. All rights reserved.
// Copyright (c) 2019-2026 ReactiveUI Association Incorporated. All rights reserved.
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

Expand Down Expand Up @@ -37,7 +37,7 @@ public ValueTask SetDisposableAsync(IAsyncDisposable? value)
var field = Volatile.Read(ref _current);
while (true)
{
if (ReferenceEquals(field, DisposedSentinel.Instance))
if (ReferenceEquals(field, DisposedSlotMarker.Instance))
{
if (value is not null)
{
Expand Down Expand Up @@ -71,8 +71,8 @@ public ValueTask SetDisposableAsync(IAsyncDisposable? value)
/// have been released.</returns>
public ValueTask DisposeAsync()
{
var field = Interlocked.Exchange(ref _current, DisposedSentinel.Instance);
if (!ReferenceEquals(field, DisposedSentinel.Instance) && field is not null)
var field = Interlocked.Exchange(ref _current, DisposedSlotMarker.Instance);
if (!ReferenceEquals(field, DisposedSlotMarker.Instance) && field is not null)
{
// Dispose the current resource asynchronously.
var disposeTask = field.DisposeAsync();
Expand All @@ -90,12 +90,12 @@ public ValueTask DisposeAsync()
/// <summary>
/// A sentinel object used to indicate that the <see cref="SingleReplaceableDisposableAsync"/> has been disposed.
/// </summary>
internal sealed class DisposedSentinel : IAsyncDisposable
internal sealed class DisposedSlotMarker : IAsyncDisposable
{
/// <summary>
/// Gets the singleton instance of <see cref="DisposedSentinel"/>.
/// Gets the singleton instance of <see cref="DisposedSlotMarker"/>.
/// </summary>
public static readonly DisposedSentinel Instance = new();
public static readonly DisposedSlotMarker Instance = new();

/// <inheritdoc/>
public ValueTask DisposeAsync() => default;
Expand Down
Loading
Loading