It's so much faster when getting lots of updates, especially with the 'Added client for' log storm at startup.
40 lines
1.2 KiB
Rust
40 lines
1.2 KiB
Rust
/*
|
|
* Copyright (C) 2023 Valentin Lorentz
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License version 3,
|
|
* as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
/// Storage for the result of pre-computations by the UI, with interior mutability
|
|
#[derive(Clone)]
|
|
pub(crate) struct PrerenderInner {
|
|
pub(crate) key: u16, // width
|
|
pub(crate) value: PrerenderValue,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) enum PrerenderValue {
|
|
Rendered(ratatui::buffer::Buffer),
|
|
NotRendered(u64), // Height only. The widget was not rendered because off-screen.
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct Prerender(pub(crate) Arc<Mutex<Option<PrerenderInner>>>);
|
|
|
|
impl Prerender {
|
|
pub fn new() -> Prerender {
|
|
Prerender(Arc::new(Mutex::new(None)))
|
|
}
|
|
}
|