From c9785e8cc5b6a9a722ba0aff1eb33c2dbf020f2e Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 23 May 2024 15:42:07 +0200 Subject: core: use mutex from parking_lot library --- core/src/async_util/task_group.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'core/src/async_util/task_group.rs') diff --git a/core/src/async_util/task_group.rs b/core/src/async_util/task_group.rs index 5af75ed..63c1541 100644 --- a/core/src/async_util/task_group.rs +++ b/core/src/async_util/task_group.rs @@ -1,4 +1,6 @@ -use std::{future::Future, sync::Arc, sync::Mutex}; +use std::{future::Future, sync::Arc}; + +use parking_lot::Mutex; use crate::async_runtime::{global_executor, Executor, Task}; @@ -67,17 +69,17 @@ impl TaskGroup { callback, self.stop_signal.clone(), ); - self.tasks.lock().unwrap().push(task); + self.tasks.lock().push(task); } /// Checks if the TaskGroup is empty. pub fn is_empty(&self) -> bool { - self.tasks.lock().unwrap().is_empty() + self.tasks.lock().is_empty() } /// Get the number of the tasks in the group. pub fn len(&self) -> usize { - self.tasks.lock().unwrap().len() + self.tasks.lock().len() } /// Cancels all tasks in the group. @@ -85,7 +87,7 @@ impl TaskGroup { self.stop_signal.broadcast().await; loop { - let task = self.tasks.lock().unwrap().pop(); + let task = self.tasks.lock().pop(); if let Some(t) = task { t.cancel().await } else { -- cgit v1.2.3