matklad / once_cell

Rust library for single assignment cells and lazy statics without macros
Apache License 2.0
1.84k stars 110 forks source link

Async support #157

Closed danieldg closed 2 years ago

danieldg commented 3 years ago

This adds new types for thread-safe cells whose initialization functions are async. This must be distinct from the sync cell because Futures-style blocking should not be used to block sync threads (and vice versa).

matklad commented 3 years ago

I suggest publishing this as a separate crate (which can be linked-to from onec_cell docs): the code is very different from what once_cell is doing, so I don't think there's a lot of benefit in keeping this in the same crate.

danieldg commented 3 years ago

Published as https://crates.io/crates/async-once-cell

matklad commented 2 years ago

Took a while, but pointer to async_once_cell is now in the docs! https://docs.rs/once_cell/latest/once_cell/#faq