multithreading

This commit is contained in:
2025-06-29 22:56:53 +02:00
parent 85bfa0f45f
commit bbaa9d09e1
5 changed files with 35 additions and 18 deletions
+7 -4
View File
@@ -6,21 +6,24 @@ use std::{
use crate::render_scope::RenderScope;
pub trait Element {
pub type BoxedElement = Box<dyn Element + Send + Sync>;
pub type BoxedComponent = Box<dyn Component + Send + Sync>;
pub trait Element: Send + Sync {
#[allow(unused)]
fn render(&mut self, scope: &mut RenderScope) {}
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
}
pub trait Component {
pub trait Component: Send + Sync {
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
}
pub struct Widget(
pub Mutex<Box<dyn Element>>,
Mutex<HashMap<TypeId, Box<dyn Component>>>,
pub Mutex<BoxedElement>,
Mutex<HashMap<TypeId, BoxedComponent>>,
);
impl Widget {