feat: spawn docker updates into own thread

Collects spawns into a hashmap, then on next update if spawn exists in hash map, don't bother to run another update
This commit is contained in:
Jack Wills
2022-07-23 02:46:38 +00:00
parent f5504c47c5
commit d0f617820c
7 changed files with 128 additions and 83 deletions
+5 -17
View File
@@ -10,7 +10,7 @@ use super::Header;
#[derive(Debug, Clone)]
pub struct StatefulList<T> {
pub state: ListState,
// HASH MAP!
// todo BTreeMap
pub items: Vec<T>,
}
@@ -84,7 +84,6 @@ impl<T> StatefulList<T> {
}
/// States of the container
// / impl ord
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum State {
Dead,
@@ -96,17 +95,6 @@ pub enum State {
Unknown,
}
// impl Ord for State {
// fn cmp(&self, other: &Self) -> Ordering {
// match (self, other) {
// (Self::Dead)
// // (_, Foo::B) => Ordering::Less,
// // (Foo::A { val: l }, Foo::A { val: r }) => l.cmp(&r),
// // (Foo::B, _) => Ordering::Greater,
// }
// }
// }
impl State {
pub fn get_color(&self) -> Color {
match self {
@@ -331,8 +319,8 @@ pub struct ContainerItem {
pub mem_limit: ByteStats,
pub mem_stats: VecDeque<ByteStats>,
pub name: String,
pub net_rx: ByteStats,
pub net_tx: ByteStats,
pub rx: ByteStats,
pub tx: ByteStats,
pub state: State,
pub status: String,
}
@@ -355,8 +343,8 @@ impl ContainerItem {
mem_limit: ByteStats::new(0),
mem_stats: VecDeque::with_capacity(60),
name,
net_rx: ByteStats::new(0),
net_tx: ByteStats::new(0),
rx: ByteStats::new(0),
tx: ByteStats::new(0),
state,
status,
}