mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
strengthen signals-received atomics (#5132)
* strengthen signals-received atomics * Update node/overseer/overseer-gen/src/lib.rs Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com> * fmt Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a69330f081
commit
1d695612c4
@@ -196,13 +196,15 @@ pub struct SignalsReceived(Arc<AtomicUsize>);
|
||||
impl SignalsReceived {
|
||||
/// Load the current value of received signals.
|
||||
pub fn load(&self) -> usize {
|
||||
// off by a few is ok
|
||||
self.0.load(atomic::Ordering::Relaxed)
|
||||
// It's imperative that we prevent reading a stale value from memory because of reordering.
|
||||
// Memory barrier to ensure that no reads or writes in the current thread before this load are reordered.
|
||||
// All writes in other threads using release semantics become visible to the current thread.
|
||||
self.0.load(atomic::Ordering::Acquire)
|
||||
}
|
||||
|
||||
/// Increase the number of signals by one.
|
||||
pub fn inc(&self) {
|
||||
self.0.fetch_add(1, atomic::Ordering::Acquire);
|
||||
self.0.fetch_add(1, atomic::Ordering::AcqRel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user