Use sync RwLock for debug_logging

This avoids the need for potentially expensive block_in_place(),
but is unlikely to actually block the thread as holding write lock is rare.
This commit is contained in:
link2xt
2023-04-16 18:48:06 +00:00
parent 2b7ee85e30
commit 4716fcef94
5 changed files with 17 additions and 9 deletions

View File

@@ -105,7 +105,12 @@ impl SchedulerState {
// to allow for clean shutdown.
context.new_msgs_notify.notify_one();
if let Some(debug_logging) = context.debug_logging.read().await.as_ref() {
if let Some(debug_logging) = context
.debug_logging
.read()
.expect("RwLock is poisoned")
.as_ref()
{
debug_logging.loop_handle.abort();
}
let prev_state = std::mem::replace(&mut *inner, new_state);