Skip to content

CSHARP-3458: Extend IAsyncCursor and IAsyncCursorSource to support IAsyncEnumerable #1708

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adelinowona
Copy link
Contributor

@adelinowona adelinowona commented Jun 12, 2025

No description provided.

@adelinowona adelinowona requested a review from a team as a code owner June 12, 2025 16:05
@adelinowona adelinowona requested review from sanych-sun and removed request for a team June 12, 2025 16:05
@adelinowona adelinowona requested review from rstam and BorisDog and removed request for sanych-sun June 12, 2025 16:06
Copy link
Contributor

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sanych-sun
Copy link
Member

As far as I know IAsyncEnumerator implements IAsyncDisposable interface to perform async clean up. I know that current implementation of AsyncCursor do not implements IAsyncDisposable, but there is an async method for clean up (see CloseIfNotAlreadyClosedAsync). Should we add support of IAsyncDisposable to AsyncCursor (probably in separate ticket/PR)?

public ValueTask DisposeAsync()
{
Dispose();
return new ValueTask(Task.CompletedTask);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be simply default.

return _batchEnumerator.MoveNext();
}

_batchEnumerator = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we dispose _batchEnumerator here?

{
// private fields
private readonly CancellationToken _cancellationToken;
private readonly IAsyncCursorSource<TDocument> _source;

// constructors
public AsyncCursorSourceEnumerableAdapter(IAsyncCursorSource<TDocument> source)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to call another constructor here, like:
: this(source, CancellationToken.None)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants