]> git.lizzy.rs Git - rust.git/blob - library/std/src/sync/mpsc/cache_aligned.rs
Merge commit '7b73b60faca71d01d900e49831fcb84553e93019' into sync-rustfmt
[rust.git] / library / std / src / sync / mpsc / cache_aligned.rs
1 use crate::ops::{Deref, DerefMut};
2
3 #[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4 #[cfg_attr(target_arch = "aarch64", repr(align(128)))]
5 #[cfg_attr(not(target_arch = "aarch64"), repr(align(64)))]
6 pub(super) struct CacheAligned<T>(pub T);
7
8 impl<T> Deref for CacheAligned<T> {
9     type Target = T;
10     fn deref(&self) -> &Self::Target {
11         &self.0
12     }
13 }
14
15 impl<T> DerefMut for CacheAligned<T> {
16     fn deref_mut(&mut self) -> &mut Self::Target {
17         &mut self.0
18     }
19 }
20
21 impl<T> CacheAligned<T> {
22     pub(super) fn new(t: T) -> Self {
23         CacheAligned(t)
24     }
25 }