Releases: timcassell/ProtoPromise
Releases · timcassell/ProtoPromise
v2.5.4
Fixes:
- Fixed
IndexOutOfRangeException
when aPromiseYielder
function is used more than 64 times simultaneously.
v2.5.3
Fixes:
- Fixed circular await detection with
Promise.ParallelForEach
andPromise.ParallelFor
.
Optimizations:
- Reduced memory of
CancelationSource
. - Reduced memory of linked
CancelationToken
s.
v2.5.2
Fixes:
- Fixed causality traces with
Promise.ParallelForEach
andPromise.ParallelFor
. - Fixed circular await detection with
Promise.ParallelForEach
andPromise.ParallelFor
. - Fixed
Promise.Canceled()
caused the parent promise to be mutated after it was repooled.
Optimizations:
- Reduced memory and cpu of
Promise.ParallelForEach
andPromise.ParallelFor
. - Reduced memory and cpu of
Promise.Run
. - Reduced memory and cpu of
Promise.New
. - Optimized internal context callbacks.
v2.5.1
Fixes:
- Included IL2CPP fixes in .Net Standard 2.1 nuget package.
- Fixed a race condition with linked
CancelationToken
s when object pooling is enabled. - Fixed a race condition when
Deferred.ReportProgress
is called concurrently withDeferred.Resolve/Reject/Cancel
.
v2.5.0
Enhancements:
- Added
AsyncLazy
type. - Added more async synchronization primitives in the
Proto.Promises.Threading
namespace:AsyncReaderWriterLock
AsyncManualResetEvent
AsyncAutoResetEvent
AsyncSemaphore
AsyncCountdownEvent
AsyncConditionVariable
- Added
AsyncMonitor.TryEnter(Async)
acceptingCancelationToken
parameter. - Added APIs to wait for promise result without throwing. These get the result wrapped in
Promise(<T>).ResultContainer
, instead of throwing if the promise was rejected or canceled.Promise(<T>).AwaitNoThrow()
Promise(<T>).AwaitWithProgressNoThrow()
.Promise.(Try)WaitNoThrow
Promise<T>.(Try)WaitForResultNoThrow
.
- Added
Promise(<T>).ResultContainer.RethrowIfRejectedOrCanceled
. - Added
Promise.SwitchToForegroundAwait
,Promise.SwitchToBackgroundAwait
, andPromise.SwitchToContextAwait
for more efficient context switch inasync
functions. - Added common Unity awaits in
PromiseYielder
:PromiseYielder.WaitForFrames(uint)
PromiseYielder.WaitForTime(TimeSpan)
PromiseYielder.WaitForRealTime(TimeSpan)
PromiseYielder.WaitUntil(Func<bool>)
PromiseYielder.WaitUntil<TCapture>(TCapture, Func<TCapture, bool>)
PromiseYielder.WaitWhile(Func<bool>)
PromiseYielder.WaitWhile<TCapture>(TCapture, Func<TCapture, bool>)
PromiseYielder.WaitForAsyncOperation(AsyncOperation)
PromiseYielder.WaitForEndOfFrame()
PromiseYielder.WaitForFixedUpdate()
- Create custom
await
instructions in Unity by implementingIAwaitInstruction
orIAwaitWithProgressInstruction
.
Optimizations:
Promise(<T>).Canceled()
now uses a singleton reference, instead of accessing the object pool/allocating.- Exposed
Promise.Manager.ThreadStaticSynchronizationContext
for efficient synchronousWaitAsync
, etc calls. - Fixed a progress performance degradation when an uncommon race condition occurs.
- Optimized the common case in progress reports.
- In Unity,
PromiseSynchronizationContext
is set to theSynchronizationContext.Current
instead ofUnitySynchronizationContext
. PromiseYielder.WaitOneFrame()
no longer allocates and is faster (now 4x faster thanyield return null
).
Fixes:
- Fixed
Promise.All/Merge
progress when a promise is canceled. - Domain reload disabled in Unity Editor is now supported.
Deprecated:
- deprecated
Promise.NewDeferred(CancelationToken)
. UsePromise.NewDeferred()
andCancelationToken.Register
to cancel the deferred directly. - deprecated
Promise.Wait(int)
,Promise<T>.WaitForResult(int, out T)
,AsyncMonitor.WaitAsync(AsyncLock.Key, CancelationToken)
. Use methods withTry
-prefixed of the same name. - deprecated
PromiseYielder.WaitOneFrame(CancelationToken)
. UsePromiseYielder.WaitOneFrame()
for the new optimized behavior, orPromiseYielder.WaitFor(null, CancelationToken)
for the old behavior.
Breaking Changes:
PromiseYielder.WaitOneFrame()
now returnsWaitOneFrameAwaiter
instead ofPromise
.- Unity Package Manager git url changed to
https://github.com/TimCassell/ProtoPromise.git?path=Package
(washttps://github.com/TimCassell/ProtoPromise.git?path=ProtoPromise_Unity/Assets/Plugins/ProtoPromise
).
Minor Changes:
AsyncLock.LockAsync(CancelationToken)
returns a canceled promise if the token is already canceled (and the synchronous version throwsCanceledException
).Promise(<T>).ResultContainer.Rethrow...
now throws the actual exception instead of aRethrowException
.
Misc:
- Relaxed
Promise(<T>).ResultContainer
fromreadonly ref struct
toreadonly struct
. - Exceptions from
PromiseSynchronizationContext.Send
are now wrapped inSystem.Exception
and re-thrown in old runtime. - Various xml documentation fixes.
v2.4.1
Fixes:
- Fixed
CancelationToken.IsCancelationRequested
when it was created from aSystem.Threading.CancellationToken
.
Optimizations:
- Small performance improvement in
CancelationToken.(Try)Register
.
v2.4.0
Enhancements:
- Added
Promise.ParallelFor
andPromise.ParallelForEach
APIs to run iterations concurrently and asynchronously (compare toParallel.ForEach
). - Exposed
CancelationRegistration.DisposeAsync()
in all supported runtimes. - Added
AsyncLock
andAsyncMonitor
to be able to lock around asynchronous resources (in theProto.Promises.Threading
namespace, only available in .Net Standard 2.1 or newer runtimes).
Fixes:
- Promise result values are no longer stored past the promise's lifetime.
- Fixed compilation errors in Unity 2017 when the experimental .Net 4.6 runtime is selected.
- Fixed compilation warnings in Unity when importing the ProtoPromise package through the Package Manager.
- Fixed default foreground context never being executed in Unity 2019.1 or newer.
Optimizations:
- Increased performance of progress reports.
- Increased performance of promises.
- Reduced memory consumption of
All
,Merge
,Race
, andFirst
promises.
Misc:
- Progress reports now use full 32-bit float precision instead of 16-bit fixed precision.
- Changed
Promise.Run
forceAsync
flag to default totrue
instead offalse
.
Breaking Changes:
- Changed
CancelationRegistration.DisposeAsync()
to returnPromise
instead ofValueTask
(await using
code still works the same, but may need a recompile).
v2.3.0
Enhancements:
- Added
Promise.Wait()
andPromise<T>.WaitForResult()
synchronous APIs. CancelationRegistration
now implementsIDisposable
andIAsyncDisposable
interfaces. Disposing the registration will unregister the callback, or wait for the callback to complete if it was already invoked.- Added
CancelationToken.GetRetainer()
API to reduceTryRetain
/Release
boilerplate code. - Un-deprecated
Deferred.IsValid
, and changed it to return whether theDeferred.Promise
is valid, instead of returningDeferred.IsValidAndPending
.
Fixes:
- Fixed
PromiseYielder
when different runners are used on a re-used routine. - Fixed
NullReferenceException
when the AppDomain is unloaded.
Deprecated:
- deprecated
Promise.ResultContainer.RejectContainer
, replaced withPromise.ResultContainer.RejectReason
. - deprecated
CancelationToken.Retain()
(preferTryRetain()
). - deprecated
CancelationRegistration.Unregister()
(preferTryUnregister()
orDispose()
).
Misc:
CancelationToken.Register(callback)
now returns a default registration if it failed to register instead of throwing.
Breaking Changes:
- Removed
Promise<T>.RaceWithIndex
andPromise<T>.FirstWithIndex
APIs in build targets older than .Net Standard 2.1.Promise.RaceWithIndex<T>
andPromise.FirstWithIndex<T>
APIs can be used instead.
v2.2.0
Enhancements:
- Added
Promise(<T>).AwaitWithProgress(maxProgress)
API to use current progress instead of passing in minProgress. - Added
Promise(<T>).{RaceWithIndex, FirstWithIndex}
APIs to be able to tell which promise won the race. - Added
Promise(<T>).WaitAsync(CancelationToken)
APIs, and added optionalCancelationToken
arguments to existingWaitAsync
APIs. - Added optional
bool forceAsync
arguments to existingWaitAsync
and other APIs that allow changing context.
Fixes:
- Fixed
CancelationToken
callbacks not being invoked after they are registered after the originalSystem.Threading.CancellationTokenSource
has been reset (.Net 6.0+). - Fixed a deadlock in
PromiseSynchronizationContext.Send
if the callback throws an exception. The exception is rethrown in .Net 4.5+. - Fixed
WaitAsync
andProgress
if nullSynchronizationContext
is passed in. - Fixed compile errors in Unity 5.
Optimizations:
- Slightly increased performance and decreased memory (at the cost of no longer unwinding the stack, which users can now do with the
forceAsync
flag).
Misc:
- Completely removed internal stacktraces in .Net 6 or later.
- Added net6.0 build target.
v2.1.0
Enhancements:
- Added
AsyncLocal<T>
support inasync Promise
functions.- Disabled by default, enable with
Promise.Config.AsyncFlowExecutionContextEnabled = true
.
- Disabled by default, enable with
- Added
ValueTask(<T>)
interoperability.- Use
promise.AsValueTask()
or implicit castValueTask valueTask = promise;
, orvalueTask.ToPromise()
.
- Use
- Added
System.Threading.CancellationToken
interoperability.- Use
token.ToCancelationToken()
to convert toProto.Promises.CancelationToken
, ortoken.ToCancellationToken()
to convert toSystem.Threading.CancellationToken
.
- Use
Optimizations:
- 2x - 3x performance improvement for promises and cancelation tokens.
- Reduced memory consumption of pending promises.
Misc:
- Added netstandard2.1, netcoreapp2.1, and net5.0 build targets.
v2.0.2:
Method | Registrations | Pending | Mean | Error | Allocated | Survived |
---|---|---|---|---|---|---|
CancelationRegistration | 10 | ? | 2,995.1 ns | 20.43 ns | - | 320 B |
AsyncAwait | ? | False | 871.7 ns | 1.79 ns | - | - |
ContinueWith | ? | False | 925.1 ns | 1.20 ns | - | - |
AsyncAwait | ? | True | 6,478.1 ns | 27.46 ns | - | 864 B |
ContinueWith | ? | True | 5,981.1 ns | 32.83 ns | - | 560 B |
v2.1.0:
Method | Registrations | Pending | Mean | Error | Allocated | Survived |
---|---|---|---|---|---|---|
CancelationRegistration | 10 | ? | 920.3 ns | 3.05 ns | - | 560 B |
AsyncAwait | ? | False | 344.4 ns | 2.88 ns | - | - |
ContinueWith | ? | False | 483.0 ns | 8.55 ns | - | - |
AsyncAwait | ? | True | 2,207.4 ns | 7.98 ns | - | 736 B |
ContinueWith | ? | True | 2,574.5 ns | 18.50 ns | - | 416 B |