call loopbody on a read lock
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
This commit is contained in:
parent
fcf4f3f7cf
commit
7db048937b
1 changed files with 10 additions and 25 deletions
|
@ -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",
|
||||
)),
|
||||
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>
|
||||
|
|
Loading…
Reference in a new issue