resource management

This commit is contained in:
2025-07-07 10:05:23 -05:00
parent 5fabd1a8ab
commit 3d995671cd
7 changed files with 77 additions and 82 deletions
+3 -3
View File
@@ -5,6 +5,7 @@ use crate::{
extensions::Extension,
style::{Position, Transform},
widget::Widget,
Screen,
};
pub struct VelocityExtension;
@@ -42,13 +43,12 @@ impl VelocityExtension {
}
impl Extension for VelocityExtension {
fn init(&mut self, widgets: &Vec<Arc<Widget>>) {
fn init(&mut self, screen: Arc<Screen>) {
std::thread::spawn({
let widgets = widgets.clone();
move || {
let mut tick = 0;
loop {
for widget in &widgets {
for widget in screen.widgets.lock().unwrap().iter() {
Self::apply_velocity_xy(tick, widget);
}
if tick > 1000 {