From cfb1fe27dc0491efbb840e8382f8b183d5a1c95f Mon Sep 17 00:00:00 2001 From: darkfi Date: Sat, 3 Aug 2024 14:02:47 +0200 Subject: [PATCH] wallet: ExecutorPtr = Arc> --- bin/darkwallet/src/app.rs | 9 +++++---- bin/darkwallet/src/main.rs | 2 ++ bin/darkwallet/src/net.rs | 5 +++-- bin/darkwallet/src/ui/button.rs | 3 ++- bin/darkwallet/src/ui/chatview.rs | 5 +++-- bin/darkwallet/src/ui/editbox.rs | 3 ++- bin/darkwallet/src/ui/image.rs | 3 ++- bin/darkwallet/src/ui/layer.rs | 3 ++- bin/darkwallet/src/ui/mesh.rs | 3 ++- bin/darkwallet/src/ui/mod.rs | 10 +++------- bin/darkwallet/src/ui/text.rs | 3 ++- bin/darkwallet/src/ui/win.rs | 3 ++- 12 files changed, 30 insertions(+), 22 deletions(-) diff --git a/bin/darkwallet/src/app.rs b/bin/darkwallet/src/app.rs index 1d805367f..eec5d1677 100644 --- a/bin/darkwallet/src/app.rs +++ b/bin/darkwallet/src/app.rs @@ -29,6 +29,7 @@ use crate::{ scene::{MethodResponseFn, Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId, SceneNodeType}, text2::TextShaperPtr, ui::{chatview, Button, ChatView, EditBox, Image, Mesh, RenderLayer, Stoppable, Text, Window}, + ExecutorPtr, }; //fn print_type_of(_: &T) { @@ -52,12 +53,12 @@ pub struct AsyncRuntime { signal: smol::channel::Sender<()>, shutdown: smol::channel::Receiver<()>, exec_threadpool: std::sync::Mutex>>, - ex: Arc>, + ex: ExecutorPtr, tasks: std::sync::Mutex>>, } impl AsyncRuntime { - pub fn new(ex: Arc>) -> Self { + pub fn new(ex: ExecutorPtr) -> Self { let (signal, shutdown) = smol::channel::unbounded::<()>(); Self { @@ -117,7 +118,7 @@ impl AsyncRuntime { pub struct App { sg: SceneGraphPtr2, - ex: Arc>, + ex: ExecutorPtr, render_api: RenderApiPtr, event_pub: GraphicsEventPublisherPtr, text_shaper: TextShaperPtr, @@ -126,7 +127,7 @@ pub struct App { impl App { pub fn new( sg: SceneGraphPtr2, - ex: Arc>, + ex: ExecutorPtr, render_api: RenderApiPtr, event_pub: GraphicsEventPublisherPtr, text_shaper: TextShaperPtr, diff --git a/bin/darkwallet/src/main.rs b/bin/darkwallet/src/main.rs index d619b740a..cdc6fbcc8 100644 --- a/bin/darkwallet/src/main.rs +++ b/bin/darkwallet/src/main.rs @@ -56,6 +56,8 @@ mod util; use crate::{net::ZeroMQAdapter, scene::SceneGraph, text2::TextShaper}; +pub type ExecutorPtr = Arc>; + fn panic_hook(panic_info: &std::panic::PanicInfo) { error!("panic occurred: {panic_info}"); //error!("panic: {}", std::backtrace::Backtrace::force_capture().to_string()); diff --git a/bin/darkwallet/src/net.rs b/bin/darkwallet/src/net.rs index f4bfe6fd8..2419ae8a3 100644 --- a/bin/darkwallet/src/net.rs +++ b/bin/darkwallet/src/net.rs @@ -29,6 +29,7 @@ use crate::{ expr::SExprCode, prop::{Property, PropertySubType, PropertyType, PropertyValue, Role}, scene::{SceneGraphPtr2, SceneNodeId, SceneNodeType, Slot, SlotId}, + ExecutorPtr, }; #[derive(Debug, SerialDecodable)] @@ -77,14 +78,14 @@ pub struct ZeroMQAdapter { slot_recvr: Option, Vec)>>, */ scene_graph: SceneGraphPtr2, - ex: Arc>, + ex: ExecutorPtr, zmq_rep: Mutex, zmq_pub: Mutex, } impl ZeroMQAdapter { - pub async fn new(scene_graph: SceneGraphPtr2, ex: Arc>) -> Arc { + pub async fn new(scene_graph: SceneGraphPtr2, ex: ExecutorPtr) -> Arc { let mut zmq_rep = zeromq::RepSocket::new(); zmq_rep.bind("tcp://0.0.0.0:9484").await.unwrap(); diff --git a/bin/darkwallet/src/ui/button.rs b/bin/darkwallet/src/ui/button.rs index e19fd90c3..bb9f51c05 100644 --- a/bin/darkwallet/src/ui/button.rs +++ b/bin/darkwallet/src/ui/button.rs @@ -31,6 +31,7 @@ use crate::{ prop::{PropertyBool, PropertyPtr, PropertyUint32, Role}, pubsub::Subscription, scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId, Signal}, + ExecutorPtr, }; use super::{eval_rect, get_parent_rect, read_rect, DrawUpdate, OnModify, Stoppable}; @@ -50,7 +51,7 @@ pub struct Button { impl Button { pub async fn new( - ex: Arc>, + ex: ExecutorPtr, sg: SceneGraphPtr2, node_id: SceneNodeId, event_pub: GraphicsEventPublisherPtr, diff --git a/bin/darkwallet/src/ui/chatview.rs b/bin/darkwallet/src/ui/chatview.rs index 3b5f6b671..6d84b3d37 100644 --- a/bin/darkwallet/src/ui/chatview.rs +++ b/bin/darkwallet/src/ui/chatview.rs @@ -44,6 +44,7 @@ use crate::{ scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId}, text2::{self, Glyph, GlyphPositionIter, SpritePtr, TextShaper, TextShaperPtr}, util::zip3, + ExecutorPtr, }; use super::{eval_rect, get_parent_rect, read_rect, DrawUpdate, OnModify, Stoppable}; @@ -259,7 +260,7 @@ pub struct ChatView { impl ChatView { pub async fn new( - ex: Arc>, + ex: ExecutorPtr, sg: SceneGraphPtr2, node_id: SceneNodeId, render_api: RenderApiPtr, @@ -613,7 +614,7 @@ impl ChatView { None => { //debug!(target: "ui::chatview", "no page found"); 0 - }, + } }; let page = &mut pages[idx]; diff --git a/bin/darkwallet/src/ui/editbox.rs b/bin/darkwallet/src/ui/editbox.rs index 50cc24f1d..c9f2b8c47 100644 --- a/bin/darkwallet/src/ui/editbox.rs +++ b/bin/darkwallet/src/ui/editbox.rs @@ -42,6 +42,7 @@ use crate::{ scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId}, text2::{self, Glyph, GlyphPositionIter, SpritePtr, TextShaper, TextShaperPtr}, util::zip3, + ExecutorPtr, }; use super::{eval_rect, get_parent_rect, read_rect, DrawUpdate, OnModify, Stoppable}; @@ -167,7 +168,7 @@ pub struct EditBox { impl EditBox { pub async fn new( - ex: Arc>, + ex: ExecutorPtr, sg: SceneGraphPtr2, node_id: SceneNodeId, render_api: RenderApiPtr, diff --git a/bin/darkwallet/src/ui/image.rs b/bin/darkwallet/src/ui/image.rs index 5c378fb96..06abedc70 100644 --- a/bin/darkwallet/src/ui/image.rs +++ b/bin/darkwallet/src/ui/image.rs @@ -35,6 +35,7 @@ use crate::{ scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId}, text2::{self, Glyph, GlyphPositionIter, SpritePtr, TextShaper, TextShaperPtr}, util::zip3, + ExecutorPtr, }; use super::{eval_rect, get_parent_rect, read_rect, DrawUpdate, OnModify, Stoppable}; @@ -58,7 +59,7 @@ pub struct Image { impl Image { pub async fn new( - ex: Arc>, + ex: ExecutorPtr, sg: SceneGraphPtr2, node_id: SceneNodeId, render_api: RenderApiPtr, diff --git a/bin/darkwallet/src/ui/layer.rs b/bin/darkwallet/src/ui/layer.rs index d1f6b1b45..2bfd4b19b 100644 --- a/bin/darkwallet/src/ui/layer.rs +++ b/bin/darkwallet/src/ui/layer.rs @@ -24,6 +24,7 @@ use crate::{ gfx2::{DrawCall, DrawInstruction, Rectangle, RenderApiPtr}, prop::{PropertyBool, PropertyPtr, Role}, scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId}, + ExecutorPtr, }; use super::{eval_rect, get_parent_rect, read_rect, DrawUpdate, OnModify, Stoppable}; @@ -46,7 +47,7 @@ pub struct RenderLayer { impl RenderLayer { pub async fn new( - ex: Arc>, + ex: ExecutorPtr, sg_ptr: SceneGraphPtr2, node_id: SceneNodeId, render_api: RenderApiPtr, diff --git a/bin/darkwallet/src/ui/mesh.rs b/bin/darkwallet/src/ui/mesh.rs index 756af68d9..bc1344e97 100644 --- a/bin/darkwallet/src/ui/mesh.rs +++ b/bin/darkwallet/src/ui/mesh.rs @@ -23,6 +23,7 @@ use crate::{ gfx2::{DrawCall, DrawInstruction, DrawMesh, Rectangle, RenderApiPtr, Vertex}, prop::{PropertyPtr, PropertyUint32, Role}, scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId}, + ExecutorPtr, }; use super::{eval_rect, get_parent_rect, read_rect, DrawUpdate, OnModify, Stoppable}; @@ -48,7 +49,7 @@ pub struct Mesh { impl Mesh { pub async fn new( - ex: Arc>, + ex: ExecutorPtr, sg: SceneGraphPtr2, node_id: SceneNodeId, render_api: RenderApiPtr, diff --git a/bin/darkwallet/src/ui/mod.rs b/bin/darkwallet/src/ui/mod.rs index 8ee98abca..e52d79ca5 100644 --- a/bin/darkwallet/src/ui/mod.rs +++ b/bin/darkwallet/src/ui/mod.rs @@ -25,6 +25,7 @@ use crate::{ gfx2::{DrawCall, Rectangle}, prop::{PropertyPtr, Role}, scene::{SceneGraph, SceneNode, SceneNodeId, SceneNodeType}, + ExecutorPtr, }; mod button; @@ -56,7 +57,7 @@ pub struct DrawUpdate { } pub struct OnModify { - ex: Arc>, + ex: ExecutorPtr, node_name: String, node_id: SceneNodeId, me: Weak, @@ -64,12 +65,7 @@ pub struct OnModify { } impl OnModify { - pub fn new( - ex: Arc>, - node_name: String, - node_id: SceneNodeId, - me: Weak, - ) -> Self { + pub fn new(ex: ExecutorPtr, node_name: String, node_id: SceneNodeId, me: Weak) -> Self { Self { ex, node_name, node_id, me, tasks: vec![] } } diff --git a/bin/darkwallet/src/ui/text.rs b/bin/darkwallet/src/ui/text.rs index d6b5c87cc..538f6137a 100644 --- a/bin/darkwallet/src/ui/text.rs +++ b/bin/darkwallet/src/ui/text.rs @@ -31,6 +31,7 @@ use crate::{ scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId}, text2::{self, Glyph, GlyphPositionIter, SpritePtr, TextShaper, TextShaperPtr}, util::zip3, + ExecutorPtr, }; use super::{eval_rect, get_parent_rect, read_rect, DrawUpdate, OnModify, Stoppable}; @@ -65,7 +66,7 @@ pub struct Text { impl Text { pub async fn new( - ex: Arc>, + ex: ExecutorPtr, sg: SceneGraphPtr2, node_id: SceneNodeId, render_api: RenderApiPtr, diff --git a/bin/darkwallet/src/ui/win.rs b/bin/darkwallet/src/ui/win.rs index 3d6e33f05..eb29889a2 100644 --- a/bin/darkwallet/src/ui/win.rs +++ b/bin/darkwallet/src/ui/win.rs @@ -22,6 +22,7 @@ use crate::{ gfx2::{DrawCall, GraphicsEventPublisherPtr, Rectangle, RenderApiPtr}, prop::{PropertyPtr, Role}, scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId}, + ExecutorPtr, }; use super::{OnModify, Stoppable}; @@ -39,7 +40,7 @@ pub struct Window { impl Window { pub async fn new( - ex: Arc>, + ex: ExecutorPtr, sg: SceneGraphPtr2, node_id: SceneNodeId, render_api: RenderApiPtr,