-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: implementing flexible solution
- Loading branch information
1 parent
74323fe
commit 2c5c573
Showing
17 changed files
with
88 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,12 +37,13 @@ jobs: | |
run: npm run build | ||
|
||
- name: Test | ||
uses: paambaati/[email protected] | ||
env: | ||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
with: | ||
coverageCommand: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./coverage/lcov.info | ||
coverageLocations: ${{github.workspace}}/test/Codibre.GrpcSqlProxy.Test/coverage/lcov.info:lcov | ||
run: npm run test:coverage | ||
# uses: paambaati/[email protected] | ||
# env: | ||
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
# with: | ||
# coverageCommand: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./coverage/lcov.info | ||
# coverageLocations: ${{github.workspace}}/test/Codibre.GrpcSqlProxy.Test/coverage/lcov.info:lcov | ||
|
||
- name: Semantic Release | ||
run: npm i -g @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/git @semantic-release/github @semantic-release/exec @droidsolutions-oss/semantic-release-nuget @semantic-release/release-notes-generator semantic-release @semantic-release/error | ||
|
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 |
---|---|---|
|
@@ -39,9 +39,10 @@ jobs: | |
# run: npm run docker:run | ||
|
||
- name: Test | ||
uses: paambaati/[email protected] | ||
env: | ||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
with: | ||
coverageCommand: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./coverage/lcov.info | ||
coverageLocations: ${{github.workspace}}/test/Codibre.GrpcSqlProxy.Test/coverage/lcov.info:lcov | ||
run: npm run test:coverage | ||
# uses: paambaati/[email protected] | ||
# env: | ||
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
# with: | ||
# coverageCommand: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./coverage/lcov.info | ||
# coverageLocations: ${{github.workspace}}/test/Codibre.GrpcSqlProxy.Test/coverage/lcov.info:lcov |
21 changes: 7 additions & 14 deletions
21
src/Codibre.EnumerableExtensions.Branching/AsyncBranchingBuilder.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 |
---|---|---|
@@ -1,26 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
using Codibre.EnumerableExtensions.Branching.Internal; | ||
|
||
namespace Codibre.EnumerableExtensions.Branching; | ||
public class AsyncBranchingBuilder<T>(IAsyncEnumerable<T> source) : BaseBranchingBuilder<T> | ||
public sealed class AsyncBranchingBuilder<T>(IAsyncEnumerable<T> source) : BaseBranchingBuilder<T> | ||
{ | ||
internal override async ValueTask<(LinkedNode<T>?, Task)> Iterate() | ||
internal override LinkedNode<T> Iterate(int branchCount) | ||
{ | ||
var enumerator = source.GetAsyncEnumerator(); | ||
var node = await enumerator.MoveLoose() ? new LinkedNode<T>(enumerator.Current) : null; | ||
return (node, node is null ? Task.CompletedTask : Task.Run(async () => | ||
{ | ||
try | ||
{ | ||
while (await enumerator.MoveLoose()) node = node.Next = new LinkedNode<T>(enumerator.Current); | ||
} | ||
finally | ||
{ | ||
node.End = true; | ||
} | ||
})); | ||
return new(enumerator.Current, new( | ||
async (c) => await enumerator.MoveNextAsync() ? new(enumerator.Current, c) : null, | ||
branchCount | ||
)); | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/Codibre.EnumerableExtensions.Branching/Internal/BranchContext.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,20 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Xml.XPath; | ||
|
||
namespace Codibre.EnumerableExtensions.Branching.Internal; | ||
|
||
internal sealed record BranchContext<T>(Func<BranchContext<T>, ValueTask<LinkedNode<T>?>> GetNext, int _branchCount) | ||
{ | ||
private ushort _count = 0; | ||
private readonly ushort _limit = (ushort)int.Min(_branchCount << 14, ushort.MaxValue / 2); | ||
|
||
internal async ValueTask<LinkedNode<T>?> FillNext() | ||
{ | ||
if (++_count > _limit) | ||
{ | ||
_count = 0; | ||
await Task.Yield(); | ||
} | ||
return await GetNext(this); | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
src/Codibre.EnumerableExtensions.Branching/Internal/BranchedEnumerable.cs
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
src/Codibre.EnumerableExtensions.Branching/Internal/BranchedEnumerator.cs
This file was deleted.
Oops, something went wrong.
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
6 changes: 2 additions & 4 deletions
6
src/Codibre.EnumerableExtensions.Branching/Internal/LinkedNode.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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
namespace Codibre.EnumerableExtensions.Branching.Internal; | ||
|
||
internal record LinkedNode<T>(T value) | ||
internal sealed record LinkedNode<T>(T Value, BranchContext<T> Context) | ||
{ | ||
public T Value { get; } = value; | ||
public LinkedNode<T>? Next { get; set; } = null; | ||
public bool End { get; set; } = false; | ||
public Lazy<ValueTask<LinkedNode<T>?>> Next { get; } = new(Context.FillNext, LazyThreadSafetyMode.ExecutionAndPublication); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...re.EnumerableExtensions.Branching.Test/Codibre.EnumerableExtensions.Branching.Test.csproj
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