Skip to content

Commit c962adf

Browse files
committed
Update version, readme, and changelog.
Increased test timeouts.
1 parent 03d300e commit c962adf

File tree

7 files changed

+81
-19
lines changed

7 files changed

+81
-19
lines changed

.github/workflows/dotnet-core-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
- name: Run Tests
5858
run: |
5959
dotnet test -c ${{ matrix.config }} -f net6.0 --logger "trx;logfilename=dotnet-test-results-net6.0-${{ matrix.config }}-${{ matrix.objectPooling.name }}-${{ matrix.devMode.name }}.trx" -p:ExtraDefineConstants=${{ matrix.objectPooling.symbol }} -p:DeveloperMode=${{ matrix.devMode.value }} --results-directory "./TestResults"
60-
timeout-minutes: 90
60+
timeout-minutes: 120
6161

6262
- uses: dorny/test-reporter@v1
6363
if: always()

.github/workflows/dotnet-framework-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
- name: Run Tests
4949
run: dotnet test -c ${{ matrix.config }} -f net472 --logger "trx;logfilename=dotnet-test-results-net472-${{ matrix.config }}-${{ matrix.objectPooling.name }}.trx" -p:ExtraDefineConstants=${{ matrix.objectPooling.symbol }} --results-directory "./TestResults"
50-
timeout-minutes: 90
50+
timeout-minutes: 120
5151

5252
- uses: dorny/test-reporter@v1
5353
if: always()

Package/CHANGELOG.md

+27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
# Change Log
22

3+
## v2.6.0 - October 2, 2023
4+
5+
Enhancements:
6+
7+
- Added `Promise.AllSettled` and `Promise.MergeSettled` APIs.
8+
- Added message between causality stack traces (matches behavior of `ExceptionDispatchInfo`).
9+
10+
Fixes:
11+
12+
- Fixed a `NullReferenceException` when `PromiseYielder` is used after `OnApplicationQuit`.
13+
- Fixed a race condition with progress.
14+
- Fixed a race condition with cancelations (was not an issue in RELEASE mode).
15+
- Fixed causality trace not being preserved when a progress callback is invoked synchronously from an already resolved promise.
16+
17+
Optimizations:
18+
19+
- Fixed PromiseMethodBuilders allocating in tier0 jit.
20+
- Object pool uses pointers for clear event instead of delegates in C# 9.
21+
- Use `Interlocked` instead of lock for faster `Promise.ParallelFor`.
22+
- Optimized `PromiseSynchronizationContext.Post`.
23+
- Other small miscellaneous performance improvements.
24+
25+
Deprecated:
26+
27+
- Deprecated `ResultContainer.Result`, renamed to `ResultContainer.Value`.
28+
- Deprecated `ResultContainer.RejectReason`, renamed to `ResultContainer.Reason`.
29+
330
## v2.5.4 - June 17, 2023
431

532
Fixes:

Package/README.md

+49-14
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ See the [C# Asynchronous Benchmarks Repo](https://github.com/timcassell/CSharpAs
4545

4646
## Latest Updates
4747

48-
## v2.5.4 - June 17, 2023
48+
### v2.6.0 - October 2, 2023
4949

50-
- Fixed `IndexOutOfRangeException` when a `PromiseYielder` function is used more than 64 times simultaneously.
50+
- Added `Promise.AllSettled` and `Promise.MergeSettled` APIs.
51+
- Fixed a `NullReferenceException` after `OnApplicationQuit`.
52+
- Fixed some race conditions.
53+
- Performance improvements.
54+
- Renamed `ResultContainer` properties to more closely match ES6.
5155

5256
See [ChangeLog](../Package/CHANGELOG.md) for the full changelog.
5357

@@ -70,10 +74,11 @@ See [ChangeLog](../Package/CHANGELOG.md) for the full changelog.
7074
- [Promises that are already settled](#promises-that-are-already-settled)
7175
- [Progress reporting](#progress-reporting)
7276
- [Combining Multiple Async Operations](#combining-multiple-async-operations)
73-
- [All Parallel](#all-parallel)
74-
- [Merge Parallel](#merge-parallel)
75-
- [Race Parallel](#race-parallel)
76-
- [First Parallel](#first-parallel)
77+
- [All](#all)
78+
- [Merge](#merge)
79+
- [AllSettled and MergeSettled](#allsettled-and-mergesettled)
80+
- [Race](#race)
81+
- [First](#first)
7782
- [Sequence](#sequence)
7883
- [Task Interoperability](#task-interoperability)
7984
- [Unity Coroutines Interoperability](#unity-coroutines-interoperability)
@@ -564,11 +569,11 @@ async Promise Func()
564569

565570
## Combining Multiple Async Operations
566571

567-
### All Parallel
572+
### All
568573

569-
The `All` function combines multiple async operations to run in parallel. It converts a collection of promises or a variable length parameter list of promises into a single promise that yields a collection.
574+
The `All` function combines multiple async operations that are currently running. It converts a collection of promises or a variable length parameter list of promises into a single promise, and if those promises are non-void, it yields a list containing the results of those promises in the same order.
570575

571-
Say that each promise yields a value of type T, the resulting promise then yields a collection with values of type T.
576+
Say that each promise yields a value of type `string`, the resulting promise then yields an `IList<string>`.
572577

573578
Here is an example that extracts links from multiple pages and merges the results:
574579

@@ -590,7 +595,7 @@ Promise.All(Download("http://www.google.com"), Download("http://www.bing.com"))
590595

591596
Progress from an All promise will be normalized from all of the input promises.
592597

593-
### Merge Parallel
598+
### Merge
594599

595600
The `Merge` function behaves just like the `All` function, except that it can be used to combine multiple types, and instead of yielding an `IList<T>`, it yields a `ValueTuple<>` that contains the types of the promises provided to the function.
596601

@@ -603,7 +608,37 @@ Promise.Merge(Download("http://www.google.com"), DownloadImage("http://www.examp
603608
})
604609
```
605610

606-
### Race Parallel
611+
### AllSettled and MergeSettled
612+
613+
The `AllSettled` and `MergeSettled` functions behave very similar to `All` and `Merge`, except they yield a collection/tuple of `ResultContainer`s instead of the raw type. This is because they capture the state of each promise. The returned promise waits until all promises are complete, whether they are resolved, rejected, or canceled (in contrast, `All` and `Merge` immediately reject or cancel the returned promise when any promise is rejected or canceled).
614+
615+
```cs
616+
Promise.MergeSettled(Download("http://www.google.com"), DownloadImage("http://www.example.com/image.jpg")) // Download HTML and image.
617+
.Then(resultContainers => // Receives ValueTuple<Promise<string>.ResultContainer, Promise<Texture>.ResultContainer>.
618+
{
619+
var result1 = resultContainers.Item1;
620+
var result2 = resultContainers.Item2;
621+
if (result1.State == Promise.State.Resolved)
622+
{
623+
Console.WriteLine(result1.Value); // Print the HTML.
624+
}
625+
else if (result1.State == Promise.State.Rejected)
626+
{
627+
Console.WriteLine(result1.Reason); // Print the reject reason.
628+
}
629+
630+
if (result2.State == Promise.State.Resolved)
631+
{
632+
image.SetTexture(result2.Value); // Assign the texture to an image object.
633+
}
634+
else if (result2.State == Promise.State.Rejected)
635+
{
636+
Console.WriteLine(result2.Reason); // Print the reject reason.
637+
}
638+
})
639+
```
640+
641+
### Race
607642

608643
The `Race` function is similar to the `All` function, but it is the first async operation that settles that wins the race and the promise adopts its state.
609644

@@ -615,7 +650,7 @@ Promise.Race(Download("http://www.google.com"), Download("http://www.bing.com"))
615650

616651
Progress from a Race promise will be the maximum of those reported by all the input promises.
617652

618-
### First Parallel
653+
### First
619654

620655
The `First` function is almost idential to `Race` except that if a promise is rejected or canceled, the First promise will remain pending until one of the input promises is resolved or they are all rejected/canceled.
621656

@@ -1049,7 +1084,7 @@ Normally when you await a promise in an `async Promise` function, it will throw
10491084
var resultContainer = await promise.AwaitNoThrow();
10501085
resultContainer.RethrowIfRejected();
10511086
bool isCanceled = resultContainer.State == Promise.State.Canceled;
1052-
var result = resultContainer.Result;
1087+
var result = resultContainer.Value;
10531088
```
10541089

10551090
### Switching Execution Context
@@ -1163,7 +1198,7 @@ public static Promise ForAsync(int min, int max, Action<int> action)
11631198
}
11641199
```
11651200

1166-
(`Promise.ParallelForEach` is similar to `Parallel.ForEachAsync` in .Net 6+, but uses `Promise` instead of `Task` to be more efficient, and works in older runtimes. And even in newer runtimes, `Parallel.ForAsync` does not exist.)
1201+
(`Promise.ParallelForEach` is similar to `Parallel.ForEachAsync` in .Net 6+, but uses `Promise` instead of `Task` to be more efficient, and works in older runtimes.)
11671202

11681203
### Async Synchronization Primitives
11691204

Package/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.timcassell.protopromise",
3-
"version": "2.5.4",
3+
"version": "2.6.0",
44
"displayName": "ProtoPromise",
55
"description": "Robust and efficient library for management of asynchronous operations.",
66
"changelogUrl": "https://github.com/timcassell/ProtoPromise/blob/master/Package/CHANGELOG.md",

ProtoPromise/ProtoPromise.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>net35;net40;net45;net47;netstandard2.0;netstandard2.1;netcoreapp2.1;net5.0;net6.0</TargetFrameworks>
55
<Configurations>Release;Debug;Release_NoProgress;Debug_NoProgress</Configurations>
6-
<Version>2.5.4</Version>
6+
<Version>2.6.0</Version>
77
<!--Set true to help debug internal promise code (allows the debugger to step into the code and includes internal stacktraces).-->
88
<DeveloperMode>false</DeveloperMode>
99
</PropertyGroup>

ProtoPromiseUnityHelpers/ProtoPromiseUnityHelpers.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!--We target .Net Framework 3.5 to support old Unity versions, and we also target .Net Standard 2.1 to support new Unity versions, even after it drops old Framework support.-->
55
<TargetFrameworks>net35;netstandard2.1</TargetFrameworks>
66
<Configurations>Release;Debug;</Configurations>
7-
<Version>2.5.4</Version>
7+
<Version>2.6.0</Version>
88
</PropertyGroup>
99

1010
<PropertyGroup>

0 commit comments

Comments
 (0)