ProtoPromise - async operation management

Update: v3 is released!

Price: FREE!

It’s an async operation management system designed for efficiency and ease of use. It’s a lightweight replacement for built-in Tasks with a more intuitive API surface. If you’re comfortable with javascript promises, you’ll be comfortable with ProtoPromise!

Features:

  • Allocation-free async operations

  • Cancelable operations with custom allocation-free CancelationToken/Source

  • Allocation-free async iterators with async Linq

  • Progress with enforced normalization

  • async/await support and .Then API

  • Error handling

  • Thread safe

  • Full causality traces

  • Easily switch to foreground or background context

  • Combine async operations

  • Circular await detection

  • Interoperable with Tasks and Unity’s Coroutines and Awaitables

ProtoPromise is the most efficient async library!

7948252--1386980--upload_2024-3-18_16-41-19.png

Compatibility: Unity 2018.3 or newer (with C# 7.3 or newer support).

Install directly from GitHub using Unity Package Manager (see instructions in the installation guide).
Or get it from the Asset Store ProtoPromise | Integration | Unity Asset Store.
Or, if you prefer, you may download the unitypackage directly from the GitHub releases page.

v2.0.2 is released with bug fixes and optimizations.

v2.1.0 is out now!

  • Big performance improvements (2x - 3x).
  • Interoperability with ValueTask and System.Threading.CancellationToken.
  • AsyncLocal<T> is now supported (must be enabled in the Config).

v2.2.0 is released!

  • 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.

v2.3.0 is released!

  • 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.

I forgot to update this thread for v2.4.0!

  • Added Promise.ParallelFor and Promise.ParallelForEach APIs to run iterations concurrently and asynchronously (compare to Parallel.ForEach).

  • Added AsyncLock and AsyncMonitor to be able to lock around asynchronous resources (in the Proto.Promises.Threading namespace, only available in Unity 2021.2 or newer).

  • Exposed CancelationRegistration.DisposeAsync() in older Unity versions.

  • Performance improvements.

  • Bug fixes.

v2.5.0 is released!

  • Added AsyncLazy type.

  • Added more async synchronization primitives in the Proto.Promises.Threading namespace:

    • AsyncReaderWriterLock
    • AsyncManualResetEvent
    • AsyncAutoResetEvent
    • AsyncSemaphore
    • AsyncCountdownEvent
    • AsyncConditionVariable
  • Added APIs to wait for promise result without throwing.

  • 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.

  • PromiseYielder.WaitOneFrame() no longer allocates and is faster (now 4x faster than yield return null).

  • Fixed Promise.All/Merge progress when a promise is canceled.

  • Domain reload disabled in Unity Editor is now supported.

v2.7.0 is released!

  • Added AsyncEnumerable<T> allocation-free async iterators (requires C# 7.3 or newer).
  • Added allocation-free async Linq extensions for AsyncEnumerable<T>.
  • Added new Progress APIs.
  • Added Promise.Finally overloads accepting Func<Promise> delegates to support DisposeAsync.
  • Added PromiseYielder.{WaitForUpdate, WaitForLateUpdate} APIs.
  • Improved performance of async Promise functions in Unity 2021.2 or newer.
  • Deprecated old progress APIs (Deferred.ReportProgress, Promise.Progress, Promise.AwaitWithProgress).

v3.0.0 is released!

  • Improved performance and reduced memory.

  • Added UnityEngine.Awaitable convert to Promise extensions.

  • Removed deprecated APIs.

  • Now requires Unity with C# 7.3 or newer (Unity 2018.3).

v3.1.0 is released!

  • Added structured concurrency promise groups.
  • Added Promise(<T>).Each APIs.
  • Added Promise(<T>).GetRetainer APIs.