Switch to layer matrix instead of layer list

This commit is contained in:
2023-07-21 16:18:47 +02:00
parent 2c239b6248
commit dcf950cc66
15 changed files with 438 additions and 210 deletions

28
lib/src/atomics.rs Normal file
View File

@ -0,0 +1,28 @@
use atomic_polyfill::{AtomicU32, Ordering};
pub struct AtomicCoord {
inner: AtomicU32,
}
impl AtomicCoord {
pub const fn new() -> Self {
AtomicCoord {
inner: AtomicU32::new(0),
}
}
pub fn load(&self, ordering: Ordering) -> (u16, u16) {
let [a, b, c, d] = self.inner.load(ordering).to_ne_bytes();
let x = u16::from_ne_bytes([a, b]);
let y = u16::from_ne_bytes([c, d]);
(x, y)
}
pub fn store(&self, x: u16, y: u16, ordering: Ordering) {
let [a, b] = x.to_ne_bytes();
let [c, d] = y.to_ne_bytes();
let xy = u32::from_ne_bytes([a, b, c, d]);
self.inner.store(xy, ordering);
}
}