#immediate-mode #lazy-evaluation #tokio #future #egui #async #gui

lazy_async_promise

Primitives for lazily getting data from futures with tokio for immediate mode guis

9 releases (5 breaking)

0.6.0 Oct 17, 2024
0.5.0 May 29, 2023
0.4.0 Mar 22, 2023
0.4.0-RC1 Jan 12, 2023
0.1.2 Oct 8, 2022

#154 in Asynchronous

Download history 146/week @ 2024-07-27 411/week @ 2024-08-03 301/week @ 2024-08-10 472/week @ 2024-08-17 391/week @ 2024-08-24 211/week @ 2024-08-31 367/week @ 2024-09-07 251/week @ 2024-09-14 257/week @ 2024-09-21 199/week @ 2024-09-28 245/week @ 2024-10-05 518/week @ 2024-10-12 317/week @ 2024-10-19 268/week @ 2024-10-26 242/week @ 2024-11-02 258/week @ 2024-11-09

1,174 downloads per month

MIT license

53KB
945 lines

lazy_async_promise: Simple primitives to manage tokio and egui

Documentation CI Coverage Status License

This crate currently only features simple primitives for getting computation time off the main thread using tokio:

  • LazyVecPromise for a vector-backed storage which can be displayed while the task in progress.
  • LazyValuePromise for a single value future that can be updated during task-progress. My usage was for iterative algorithms where the intermediate results were interesting for display.

As the name suggests the two of them are lazily evaluated and nothing happens until they are polled for the first time.

For single values which are either available or not there's ImmediateValuePromise which triggers computation immediately. There's not in-calculation value read out, so either it's finished or not. After heavy usage, I currently tend to use ImmediateValuePromise wrapped in Option for most lazy values, too. Especially when no intermediate values are needed, it's technically sufficient and simpler. Also, since 0.4.0 it's very convenient to use now, see the docs for examples.

Another example usage of this crate with a small egui/eframe blog-reader can be found here

Changelog:

0.6.0

  • Added get_result and take_result to everything that implements DirectCacheAccess (Thanks @tomellm)

0.5.0

  • Fixed visibility issues with BoxSendError (thanks @aspcartman)
  • Added progress tracked wrapper for immediate value promise (made lazyvaluepromise obsolete at least for me)
  • Updated documentation

0.4.0:

  • Added more flexible API to lazy and immediate structures, allowing to take the values
  • Added DirectCacheAccess trait to make option-based usage of the immediate value promise more convenient
  • Updated documentation

0.3.1:

  • Add better api macros for lazy structures

0.3.0:

  • Removed into_boxed trait in favor of supporting the regular From trait which allows direct usage of the ?-Operator in ImmediateValuePromise
  • Added a progress indicator for the LazyVecPromise and LazyValuePromise
  • Indication is done by Progress strong type which ensures values between 0.0 and 1.0
  • Added CI for mac, windows and linux - had to give test-timings more leeway for mac os than on linux.

Dependencies

~2–7.5MB
~47K SLoC