Skip to content

Releases: timcassell/ProtoPromise

v2.5.4

17 Jun 06:20
b8176c8
Compare
Choose a tag to compare

Fixes:

  • Fixed IndexOutOfRangeException when a PromiseYielder function is used more than 64 times simultaneously.

v2.5.3

09 Jun 23:53
de18e3c
Compare
Choose a tag to compare

Fixes:

  • Fixed circular await detection with Promise.ParallelForEach and Promise.ParallelFor.

Optimizations:

  • Reduced memory of CancelationSource.
  • Reduced memory of linked CancelationTokens.

v2.5.2

05 Jun 03:14
a791930
Compare
Choose a tag to compare

Fixes:

  • Fixed causality traces with Promise.ParallelForEach and Promise.ParallelFor.
  • Fixed circular await detection with Promise.ParallelForEach and Promise.ParallelFor.
  • Fixed Promise.Canceled() caused the parent promise to be mutated after it was repooled.

Optimizations:

  • Reduced memory and cpu of Promise.ParallelForEach and Promise.ParallelFor.
  • Reduced memory and cpu of Promise.Run.
  • Reduced memory and cpu of Promise.New.
  • Optimized internal context callbacks.

v2.5.1

27 May 04:15
11a6593
Compare
Choose a tag to compare

Fixes:

  • Included IL2CPP fixes in .Net Standard 2.1 nuget package.
  • Fixed a race condition with linked CancelationTokens when object pooling is enabled.
  • Fixed a race condition when Deferred.ReportProgress is called concurrently with Deferred.Resolve/Reject/Cancel.

v2.5.0

15 May 11:00
Compare
Choose a tag to compare

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) accepting CancelationToken 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, and Promise.SwitchToContextAwait for more efficient context switch in async 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 implementing IAwaitInstruction or IAwaitWithProgressInstruction.

Optimizations:

  • Promise(<T>).Canceled() now uses a singleton reference, instead of accessing the object pool/allocating.
  • Exposed Promise.Manager.ThreadStaticSynchronizationContext for efficient synchronous WaitAsync, 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 the SynchronizationContext.Current instead of UnitySynchronizationContext.
  • PromiseYielder.WaitOneFrame() no longer allocates and is faster (now 4x faster than yield 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). Use Promise.NewDeferred() and CancelationToken.Register to cancel the deferred directly.
  • deprecated Promise.Wait(int), Promise<T>.WaitForResult(int, out T), AsyncMonitor.WaitAsync(AsyncLock.Key, CancelationToken). Use methods with Try-prefixed of the same name.
  • deprecated PromiseYielder.WaitOneFrame(CancelationToken). Use PromiseYielder.WaitOneFrame() for the new optimized behavior, or PromiseYielder.WaitFor(null, CancelationToken) for the old behavior.

Breaking Changes:

  • PromiseYielder.WaitOneFrame() now returns WaitOneFrameAwaiter instead of Promise.
  • Unity Package Manager git url changed to https://github.com/TimCassell/ProtoPromise.git?path=Package (was https://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 throws CanceledException).
  • Promise(<T>).ResultContainer.Rethrow... now throws the actual exception instead of a RethrowException.

Misc:

  • Relaxed Promise(<T>).ResultContainer from readonly ref struct to readonly struct.
  • Exceptions from PromiseSynchronizationContext.Send are now wrapped in System.Exception and re-thrown in old runtime.
  • Various xml documentation fixes.

v2.4.1

06 Feb 03:11
c1de774
Compare
Choose a tag to compare

Fixes:

  • Fixed CancelationToken.IsCancelationRequested when it was created from a System.Threading.CancellationToken.

Optimizations:

  • Small performance improvement in CancelationToken.(Try)Register.

v2.4.0

23 Dec 11:29
Compare
Choose a tag to compare

Enhancements:

  • Added Promise.ParallelFor and Promise.ParallelForEach APIs to run iterations concurrently and asynchronously (compare to Parallel.ForEach).
  • Exposed CancelationRegistration.DisposeAsync() in all supported runtimes.
  • Added AsyncLock and AsyncMonitor to be able to lock around asynchronous resources (in the Proto.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, and First promises.

Misc:

  • Progress reports now use full 32-bit float precision instead of 16-bit fixed precision.
  • Changed Promise.Run forceAsync flag to default to true instead of false.

Breaking Changes:

  • Changed CancelationRegistration.DisposeAsync() to return Promise instead of ValueTask (await using code still works the same, but may need a recompile).

v2.3.0

25 Sep 14:14
f6d1837
Compare
Choose a tag to compare

Enhancements:

  • Added Promise.Wait() and Promise<T>.WaitForResult() synchronous APIs.
  • CancelationRegistration now implements IDisposable and IAsyncDisposable 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 reduce TryRetain / Release boilerplate code.
  • Un-deprecated Deferred.IsValid, and changed it to return whether the Deferred.Promise is valid, instead of returning Deferred.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 with Promise.ResultContainer.RejectReason.
  • deprecated CancelationToken.Retain() (prefer TryRetain()).
  • deprecated CancelationRegistration.Unregister() (prefer TryUnregister() or Dispose()).

Misc:

  • CancelationToken.Register(callback) now returns a default registration if it failed to register instead of throwing.

Breaking Changes:

  • Removed Promise<T>.RaceWithIndex and Promise<T>.FirstWithIndex APIs in build targets older than .Net Standard 2.1. Promise.RaceWithIndex<T> and Promise.FirstWithIndex<T> APIs can be used instead.

v2.2.0

06 Aug 13:52
fe43b33
Compare
Choose a tag to compare

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 optional CancelationToken arguments to existing WaitAsync APIs.
  • Added optional bool forceAsync arguments to existing WaitAsync and other APIs that allow changing context.

Fixes:

  • Fixed CancelationToken callbacks not being invoked after they are registered after the original System.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 and Progress if null SynchronizationContext 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

20 Jun 03:30
Compare
Choose a tag to compare

Enhancements:

  • Added AsyncLocal<T> support in async Promise functions.
    • Disabled by default, enable with Promise.Config.AsyncFlowExecutionContextEnabled = true.
  • Added ValueTask(<T>) interoperability.
    • Use promise.AsValueTask() or implicit cast ValueTask valueTask = promise;, or valueTask.ToPromise().
  • Added System.Threading.CancellationToken interoperability.
    • Use token.ToCancelationToken() to convert to Proto.Promises.CancelationToken, or token.ToCancellationToken() to convert to System.Threading.CancellationToken.

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