Skip to content

Releases: timcassell/ProtoPromise

v2.0.0

07 Mar 14:29
25c8b6f
Compare
Choose a tag to compare

Enhancements:

  • Full library thread-safety with minimal locks.
  • Added Deferred.Cancel.
  • Added Deferred and CancelationSource and CancelationToken and CancelationRegistration Try... methods.
  • Added CancelationRegistration methods to unregister/check registration and if the token is requesting cancelation atomically.
  • Added static CancelationToken.Canceled() to get a token already in the canceled state without allocating.
  • Added Promise(<T>).WaitAsync(SynchronizationOption) and Promise(<T>).WaitAsync(SynchronizationContext) to schedule the next callback/await on the desired context.
  • Added Promise.Run static functions.
  • Added Promise.SwitchToForeground(), Promise.SwitchToBackground(), and Promise.SwitchToContext(SynchronizationContext) static functions.
  • Added Promise.AwaitWithProgress(float minProgress, float maxProgress) API to propagate the progress to an async Promise(<T>) function.

Optimizations:

  • Promises are now structs, making already resolved promises live only on the stack, increasing performance.
  • Eliminated potential StackOverflowExceptions from async/await continuations when both the async function and the awaited object are Promise(<T>).
  • Optimized async Promise(<T>) functions in Unity 2021.2 or newer when IL2CPP is used.

Breaking Changes:

  • Promises are now structs instead of classes.
  • Changed behavior of Promise.CatchCancelation to return a new promise and behave more like Promise.Catch, where onCanceled resolves the returned promise when it returns, or adopts the state of the returned promise.
  • Removed cancelation reasons.
  • A rejected promise awaited in an async function now throws the original exception, if the promise was rejected with an exception.
  • Deprecations and other breaking changes (see full release notes).

See Release Notes for the full changelog.

v1.0.3

12 Dec 04:34
Compare
Choose a tag to compare

Fixed a compile error when building with IL2CPP runtime.

v1.0.2

02 Jan 19:44
Compare
Choose a tag to compare

Fixed uncaught rejections not being reported from reused promise objects.

v1.0.1

09 Nov 20:22
Compare
Choose a tag to compare
  • Fix sln and csproj configurations.
  • Fix formatting in README.md.

v1.0.0

30 Oct 01:58
37a0f8b
Compare
Choose a tag to compare

Bug Fixes

  • Fixed PromiseMethodBuilders in non-IL2CPP builds when the TStateMachine is a struct.
  • Fixed various progress bugs.
  • Fixed CancelationToken.Equals(object).

Behavior changes

  • Added thread checks to make sure the library is only used with one thread (in DEBUG mode only).

Misc

  • Removed class restriction on PromiseYielder.WaitFor (since there are some structs that can be yielded in Coroutines, like AsyncOperationHandles).

Allocation-Free Async Promise Functions

30 Sep 06:46
Compare
Choose a tag to compare
Pre-release

Optimizations

  • Added object pooling for allocation-free async Promise functions.
  • Removed LitePromises, using DeferredPromises for Promise.Resolved/Rejected/Canceled instead to reduce amount of code.

Bug Fixes

  • Fixed causality traces in async Promise functions.
  • Fixed aggregate exception not capturing the unhandled exceptions.

Misc

  • Added message to unhandled exceptions, when not in DEBUG mode, to explain how to see causality traces.

Async Promise Functions Fix

24 Sep 00:41
Compare
Choose a tag to compare
Pre-release
  • Fixed PromiseMethodBuilders for async Promise functions with the IL2CPP compiler.
  • Ignore Internal functions and PromiseYielder.Routines in causality traces.
  • Include causality trace from invalid returned promise.

Implicit DeferredBase Cast

25 Aug 09:31
Compare
Choose a tag to compare
Pre-release

Added implicit cast operators that I forgot for Promise.Deferred -> Promise.DeferredBase and Promise<T>.Deferred -> Promise.DeferredBase.

Cancelation Tokens

21 Aug 19:45
Compare
Choose a tag to compare
Cancelation Tokens Pre-release
Pre-release

API changes

  • Added Proto.Promises.{CancelationSource, CancelationToken, CancelationRegistration} structs which can be used for synchronous cancelation callbacks.
  • Added optional CancelationToken parameter to Promise.{Then, Catch, CatchCancelation, ContinueWith, Progress, Sequence, NewDeferred}.
  • Changed Deferreds to structs with an implicit cast to DeferredBase (DeferredBase.ToDeferred(<T>)() to cast back explicitly).
  • Removed DeferredBase.Cancel, replaced with the cancelation token.
  • Removed Promise.{Cancel, ThenDuplicate}.
  • Removed Proto.Logger, replaced it with Promise.Config.WarningHandler.

Behavior changes

  • Changed Promise.First to suppress rejections from any promises passed in that did not result in the rejection of the returned promise.
  • Change Deferred.Reject(null) to convert to a NullReferenceException on any T. This means Promise.Catch<T> will never give a null value. This more closely matches normal throw null; behavior.
  • CancelationSource.Cancel(null) now converts cancelation to a non-value. This mean if Promise.ReasonContainer.ValueType is not null, Promise.ReasonContainer.Value is also not null, and if Promise.ReasonContainer.TryGetValue<T> succeeds, the value will not be null.
  • Removed requirement to include Proto.Promises.Await for awaiting promises in an async function.
  • Check to make sure RethrowException is used properly, change to InvalidOperationException if not.

Optimizations

  • Deferreds are now structs, removing the memory overhead of classes.
  • Added a static cached Promise.Canceled() void in RELEASE mode.
  • When canceled, promises are now unlinked from their previous.
  • No longer check if promise is canceled when doing internal operations.
  • Removed internal skipFrame calculations since that's now handled in Internal.FormatStackTrace in DEBUG mode.
  • Pass by ref to pass large structs around internally more efficiently.
  • Less memory used in Promise objects with onRejected callbacks.
  • PromiseMethodBuilder caches stateMachine.MoveNext directly instead of lambda capturing.

Misc

  • Removed recursive type definitions so that Unity 2019.1.14 and older on .Net 4.X scripting runtime version will compile.
  • Removed PROTO_PROMISE_CANCEL_DISABLE preprocessor checks since cancelations no longer slow down normal execution.
  • No longer check for internal promise invoking when accessing Promise.{RejectException, CancelException}.
  • Renamed asmdefs to include Proto in the names. Removed Utilities.asmdef.

Known Issues

  • A Promise.Progress callback subscribed to a promise chain where the chain is broken by a cancelation token and continued with Promise.ContinueWith reports incorrect progress (introduced in v 0.9 with Promise.ContinueWith).

ContinueWith Bug Fix

21 Aug 19:05
Compare
Choose a tag to compare
ContinueWith Bug Fix Pre-release
Pre-release

Fixed one of the ContinueWith capture methods not capturing properly.