Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change test client subscription notification collection to queue #29

Merged
merged 1 commit into from
Sep 27, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ public class LeanPipeSubscription
private readonly object notificationMutex = new();
private TaskCompletionSource<object> nextMessageAwaiter =
new(TaskCreationOptions.RunContinuationsAsynchronously);
private readonly ConcurrentStack<object> receivedNotifications = new();
private readonly ConcurrentQueue<object> receivedNotifications = new();

public ITopic Topic { get; private init; }
public Guid? SubscriptionId { get; private set; }

/// <summary>
/// A FIFO collection of received notifications.
/// </summary>
public IReadOnlyCollection<object> ReceivedNotifications => receivedNotifications;

public LeanPipeSubscription(ITopic topic, Guid? subscriptionId)
Expand All @@ -32,7 +36,7 @@ public void Unsubscribe()

public void AddNotification(object notification)
{
receivedNotifications.Push(notification);
receivedNotifications.Enqueue(notification);

lock (notificationMutex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public static async Task<object> WaitForNextNotificationOn<TTopic>(
);
}

/// <returns>A FIFO collection of received notifications on topic instance.</returns>
public static IReadOnlyCollection<object> NotificationsOn<TTopic>(
this LeanPipeTestClient client,
TTopic topic
Expand Down
Loading