WIP: issue-routine-lock-idea1 #55

Draft
mzntori wants to merge 1 commit from issue-routine-lock-idea1 into issue-routine-lock
Showing only changes of commit 7db048937b - Show all commits

View file

@ -1131,14 +1131,16 @@ impl Routine {
}
loop { // [x] Routine loop
// [x] execution body
// trg_routine_ar.read().await.loopbody().await;
{
trg_routine_ar.write().await.loopbody().await;
let mut trg_routine = trg_routine_ar.write().await;
trg_routine.parent_params.parent_act = Some(trg_routine.parent_params.curr_act.clone());
trg_routine.parent_params.curr_act = trg_routine.self_act_ar.to_owned().unwrap();
}
// [x] execution body
trg_routine_ar.read().await.loopbody().await;
{ // [x] End of Loop iteration
let mut a = trg_routine_ar.write().await;
@ -1232,40 +1234,23 @@ impl Routine {
}
async fn loopbody(&mut self)
async fn loopbody(&self)
// [x] => 03.27 - COMPLETED
{
botlog::trace(
"loopbody() started",
Some(format!(
"Routine > start() > (During Tokio Spawn) > Execution body",
)),
None,
Some("Routine > start() > (During Tokio Spawn) > Execution body".to_string()),
None,
);
Log::flush();
let self_ar = Arc::new(RwLock::new(self));
{
let mut mutlock = self_ar.write().await;
mutlock.parent_params.parent_act = Some(mutlock.parent_params.curr_act.clone());
mutlock.parent_params.curr_act = mutlock.self_act_ar.to_owned().unwrap();
}
dbg!("before");
// `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;
dbg!("after");
// (self.exec_body)(
// self.parent_params.clone()
// ).await;
}
pub async fn stop(&mut self) -> Result<String,String>