-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query: Fix memory leak by making FeedIterator IDisposable (#1613)
* Add disposable to FeedIterator.
- Loading branch information
Showing
18 changed files
with
508 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIteratorInlineCore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos | ||
{ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Cosmos.CosmosElements; | ||
|
||
internal sealed class FeedIteratorInlineCore : FeedIteratorInternal | ||
{ | ||
private readonly FeedIteratorInternal feedIteratorInternal; | ||
|
||
internal FeedIteratorInlineCore( | ||
FeedIterator feedIterator) | ||
{ | ||
if (!(feedIterator is FeedIteratorInternal feedIteratorInternal)) | ||
{ | ||
throw new ArgumentNullException(nameof(feedIterator)); | ||
} | ||
|
||
this.feedIteratorInternal = feedIteratorInternal; | ||
} | ||
|
||
internal FeedIteratorInlineCore( | ||
FeedIteratorInternal feedIteratorInternal) | ||
{ | ||
this.feedIteratorInternal = feedIteratorInternal ?? throw new ArgumentNullException(nameof(feedIteratorInternal)); | ||
} | ||
|
||
public override bool HasMoreResults => this.feedIteratorInternal.HasMoreResults; | ||
|
||
public override CosmosElement GetCosmosElementContinuationToken() | ||
{ | ||
return this.feedIteratorInternal.GetCosmosElementContinuationToken(); | ||
} | ||
|
||
public override Task<ResponseMessage> ReadNextAsync(CancellationToken cancellationToken = default) | ||
{ | ||
return TaskHelper.RunInlineIfNeededAsync(() => this.feedIteratorInternal.ReadNextAsync(cancellationToken)); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
this.feedIteratorInternal.Dispose(); | ||
base.Dispose(disposing); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.