Skip to content

v2.0.0

Compare
Choose a tag to compare
@timcassell timcassell released this 07 Mar 14:29
· 1152 commits to master since this release
25c8b6f

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.