From a38c84b8f456cfb290c2d8ce9a7c51b8c8352900 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Fri, 29 Mar 2024 23:51:41 -0400 Subject: [PATCH] smol --- src/core/bot_actions.rs | 4 +-- src/core/botmodules.rs | 34 +++++++++++++++--- src/custom/experimental/experiment003.rs | 44 ++++++++++++++++++++---- 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/src/core/bot_actions.rs b/src/core/bot_actions.rs index c7ec0c5..235637e 100644 --- a/src/core/bot_actions.rs +++ b/src/core/bot_actions.rs @@ -52,9 +52,6 @@ impl ExecBodyParams { pub async fn get_channel(&self) -> Option { - // THIS IS INCORRECT - BELOW MAY BE PULLING THE PARENT BOTACTION - // NOT THE CURRENT BOT ACTION - let curr_act = Arc::clone(&self.curr_act); let parent_act_lock = curr_act.read().await; @@ -74,6 +71,7 @@ impl ExecBodyParams { BotAction::R(r) => { // let temp = r.module.clone(); // Some(temp) + dbg!("Core > ExecBodyParams > GetChannels - routine identified"); Some(r.read().await.channel.clone()) } // _ => None diff --git a/src/core/botmodules.rs b/src/core/botmodules.rs index 32e669f..b3c8a5f 100644 --- a/src/core/botmodules.rs +++ b/src/core/botmodules.rs @@ -1232,6 +1232,10 @@ impl Routine { } + // pub async fn execute(routine:&Routine, params : ExecBodyParams) { + // (routine.exec_body)(params).await; + // } + async fn loopbody(&mut self) // [x] => 03.27 - COMPLETED { @@ -1254,15 +1258,35 @@ impl Routine { mutlock.parent_params.curr_act = mutlock.self_act_ar.to_owned().unwrap(); } - dbg!("before"); + dbg!("Core > Before Guards"); // `self_ar` is the routine you want to read in the execbody i think, but its used to call that execbody. // So execbody waits for itself to finish. - (self_ar.read().await.exec_body)( - self_ar.read().await.parent_params.clone() - ).await; + // (self_ar.read().await.exec_body)( + // self_ar.read().await.parent_params.clone() + // ).await; - dbg!("after"); + let parent_params = { + let guard1 = self_ar.read().await; + + let parent_params = guard1.parent_params.clone(); + drop(guard1); + parent_params + }; + + dbg!("Core > Guarding & Executing Child Execution Body"); + + { + let guard2 = self_ar.read().await; + (guard2.exec_body)(parent_params).await; + drop(guard2); + + } + // (self_ar.read().await.exec_body)( + // parent_params + // ).await; + + dbg!("Core > After Execution Body is completed"); // (self.exec_body)( // self.parent_params.clone() // ).await; diff --git a/src/custom/experimental/experiment003.rs b/src/custom/experimental/experiment003.rs index 41c1d65..fdcdde6 100644 --- a/src/custom/experimental/experiment003.rs +++ b/src/custom/experimental/experiment003.rs @@ -374,9 +374,9 @@ async fn test3_body(params : ExecBodyParams) { async fn rtestbody(params : ExecBodyParams) { - let guard = params.curr_act.read().await; + let guard1 = params.curr_act.read().await; { - let logmsg_botact = match *guard { + let logmsg_botact = match *guard1 { BotAction::C(_) => "command", BotAction::R(_) => "routine", BotAction::L(_) => "listener", @@ -392,7 +392,7 @@ async fn test3_body(params : ExecBodyParams) { { - let logmsg_botact = match *guard { + let logmsg_botact = match &*guard1 { BotAction::C(_) => "command 2", BotAction::R(_) => "routine 2", BotAction::L(_) => "listener 2", @@ -406,14 +406,44 @@ async fn test3_body(params : ExecBodyParams) { Log::flush(); } + // drop(guard1); + { + dbg!("Custom > within Child Custom fn - Before Critical area"); println!("Critical code area start"); // <= 03.29 - This is printed - if let BotAction::R(c) = &*guard { - println!("{:?}",c.read().await.channel); - } - println!("Critical code area end"); // <= 03.29 - ISSUE This is NOT printed + // if let BotAction::R(c) = &*guard { + // println!("{:?}",c.read().await.channel); + // } + + // let routine_channel = if let BotAction::R(c) = &*guard1 { + // dbg!("Custom > within Child Custom fn - During Critical area > Routine Guard "); + // let routineguard = c.read().await; + // Some(routineguard.channel.clone()); + // } else { + // None + // }; + + + // let chnl = match &*guard1 { + // BotAction::R(arr) => { + // dbg!("Custom > within Child Custom fn - During Critical area > Before Routine Guard "); + // let routineguard = arr.read().await; + // dbg!("Custom > within Child Custom fn - During Critical area > After Routine Guard "); + // Some(routineguard.channel.clone()) + // }, + // BotAction::C(_) | BotAction::L(_) => None , + // } ; + + let chnl = params.get_channel().await; + dbg!("Custom > within Child Custom fn - after GetChannel"); + println!("{:?}",chnl); + + + println!("Critical code area end"); // <= 03.29 - ISSUE This is NOT printed + dbg!("Custom > within Child Custom fn - Before Critical area"); + // if let BotAction::R(arr) = &*params.curr_act.read().await { // for curriter in 0..5 { // println!("tester - Routine - Completed Iterations : {}",