Skip to content

Commit

Permalink
Use portable-atomic
Browse files Browse the repository at this point in the history
This should not have run-time impact on platforms that support atomic
boolean compare-and-swap, but enables its use on microcontrollers where
the user configures portable-atomic in such a way that atomics can be
emulated (eg. through disabling interrupts).
  • Loading branch information
chrysn committed Sep 13, 2024
1 parent fd160ec commit a1aadfa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ documentation = "https://docs.rs/try-lock"
readme = "README.md"

[dependencies]
portable-atomic = { version = "1", default-features = false, features = ["require-cas"] }
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@
#[cfg(test)]
extern crate core;

extern crate portable_atomic;

use core::cell::UnsafeCell;
use core::fmt;
use core::ops::{Deref, DerefMut};
use core::sync::atomic::{AtomicBool, Ordering};
use portable_atomic::AtomicBool;
use core::sync::atomic::Ordering;
use core::marker::PhantomData;

/// A light-weight lock guarded by an atomic boolean.
Expand Down

0 comments on commit a1aadfa

Please sign in to comment.