call loopbody on a read lock
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful

This commit is contained in:
mzntori 2024-04-01 18:39:03 +02:00
parent fcf4f3f7cf
commit 7db048937b

View file

@ -1131,13 +1131,15 @@ impl Routine {
}
loop { // [x] Routine loop
{
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;
{
trg_routine_ar.write().await.loopbody().await;
}
trg_routine_ar.read().await.loopbody().await;
{ // [x] End of Loop iteration
@ -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>