-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created public `AtomicSignalSet` type. Replaces the old internal `AtomicSignalMask`. Removed internal `SignalMask` type and moved all operations onto `SignalSet`. Changed `SignalSet::with` back to not taking a `bool` and added `SignalSet::without`. Using `SignalSet::setting` matches the old behavior. Changed `remove_{first,last}` to not return the `Signal` and made `pop_{first,last}` to match the old behavior.
- Loading branch information
Showing
9 changed files
with
230 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use std::sync::atomic::{AtomicU32, Ordering}; | ||
|
||
use super::SignalSet; | ||
|
||
/// A set of signals with atomic operations. | ||
pub struct AtomicSignalSet(AtomicU32); | ||
|
||
impl From<SignalSet> for AtomicSignalSet { | ||
#[inline] | ||
fn from(signals: SignalSet) -> Self { | ||
Self::from_signal_set(signals) | ||
} | ||
} | ||
|
||
impl AtomicSignalSet { | ||
/// Creates a new, empty signal set. | ||
#[inline] | ||
pub const fn new() -> Self { | ||
Self::from_signal_set(SignalSet::new()) | ||
} | ||
|
||
/// Creates a new atomic signal set from `signals`. | ||
#[inline] | ||
pub const fn from_signal_set(signals: SignalSet) -> Self { | ||
Self(AtomicU32::new(signals.0)) | ||
} | ||
|
||
/// Atomically loads the inner `SignalSet` using `ordering`. | ||
#[inline] | ||
#[must_use] | ||
pub fn load(&self, ordering: Ordering) -> SignalSet { | ||
SignalSet(self.0.load(ordering)) | ||
} | ||
|
||
/// Atomically stores the `signals` in `self` using `ordering`. | ||
#[inline] | ||
pub fn store<S: Into<SignalSet>>(&self, signals: S, ordering: Ordering) { | ||
self.0.store(signals.into().0, ordering); | ||
} | ||
|
||
/// Atomically inserts `signals` into `self` using `ordering`. | ||
#[inline] | ||
pub fn insert<S: Into<SignalSet>>( | ||
&self, | ||
signals: S, | ||
ordering: Ordering, | ||
) -> SignalSet { | ||
SignalSet(self.0.fetch_or(signals.into().0, ordering)) | ||
} | ||
} |
Oops, something went wrong.