smol
This commit is contained in:
parent
fcf4f3f7cf
commit
a38c84b8f4
3 changed files with 67 additions and 15 deletions
|
@ -52,9 +52,6 @@ impl ExecBodyParams {
|
|||
|
||||
pub async fn get_channel(&self) -> Option<Channel> {
|
||||
|
||||
// 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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,13 +406,43 @@ 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);
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
|
Loading…
Reference in a new issue