]> git.proxmox.com Git - rustc.git/blob - src/libstd/sync/mpsc/cache_aligned.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / libstd / sync / mpsc / cache_aligned.rs
1 use crate::ops::{Deref, DerefMut};
2
3 #[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4 #[repr(align(64))]
5 pub(super) struct Aligner;
6
7 #[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
8 pub(super) struct CacheAligned<T>(pub T, pub Aligner);
9
10 impl<T> Deref for CacheAligned<T> {
11 type Target = T;
12 fn deref(&self) -> &Self::Target {
13 &self.0
14 }
15 }
16
17 impl<T> DerefMut for CacheAligned<T> {
18 fn deref_mut(&mut self) -> &mut Self::Target {
19 &mut self.0
20 }
21 }
22
23 impl<T> CacheAligned<T> {
24 pub(super) fn new(t: T) -> Self {
25 CacheAligned(t, Aligner)
26 }
27 }