Rework wait primitive to condvar

This commit is contained in:
2021-08-20 15:57:12 +00:00
parent e7222a99b5
commit d2c811d3af
4 changed files with 421 additions and 338 deletions

View File

@@ -53,6 +53,16 @@ impl<T> Direction<T> {
east: (self.east, other.east),
}
}
/// Flips all direction through origo
pub fn opposite(self) -> Self {
Self {
north: self.south,
south: self.north,
east: self.west,
west: self.east,
}
}
}
impl<T> Direction<Option<T>> {
@@ -96,6 +106,15 @@ impl<T> Direction<T> {
}
}
impl Direction<bool> {
pub fn all(&self) -> bool {
self.north && self.south && self.east && self.west
}
pub fn any(&self) -> bool {
self.north || self.south || self.east || self.west
}
}
/// Linearly spaced parameters, apart from the boundaries which
/// only have a distance of `h/2` from the boundary
pub fn h2linspace(start: Float, end: Float, n: usize) -> ndarray::Array1<Float> {