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

Add `no_std` implementation based on `critical-section`. #195

Closed reitermarkus closed 1 year ago

reitermarkus commented 2 years ago

Add implementation based on critical-section for embedded targets.

This started out using critical_section::Mutex, but tests were failing since critical_section::with blocks all threads during initialization, so I changed it to be basically the same as imp_pl without the parking_lot parts, since atomic-polyfill is based on critical-section.

Depends on https://github.com/rust-embedded/critical-section/pull/26.

reitermarkus commented 2 years ago

Okay, so I have a different implementation which doesn't spin and simply completely blocks all threads during initialize, but this causes cargo test to deadlock unless using --test-threads 1.

reitermarkus commented 2 years ago

@matklad, can you have another look?

reitermarkus commented 1 year ago

@matklad, can you have another look at this? Thanks.

matklad commented 1 year ago

lgtm!

bors r+

bors[bot] commented 1 year ago

Build succeeded: