use parking_lot::Mutex instead of tokio::sync::Mutex
This commit is contained in:
Generated
+1
@@ -1334,6 +1334,7 @@ dependencies = [
|
||||
"futures",
|
||||
"httpdate",
|
||||
"maxminddb",
|
||||
"parking_lot",
|
||||
"rand 0.9.2",
|
||||
"ratatui",
|
||||
"reqwest",
|
||||
|
||||
@@ -15,6 +15,7 @@ fancy-regex = "=0.16.1"
|
||||
futures = { version = "=0.3.31", optional = true }
|
||||
httpdate = "=1.0.3"
|
||||
maxminddb = { version = "=0.26.0", features = ["mmap"] }
|
||||
parking_lot = "=0.12.4"
|
||||
rand = "=0.9.2"
|
||||
ratatui = { version = "=0.29.0", optional = true }
|
||||
rlimit = "=0.10.2"
|
||||
@@ -62,3 +63,4 @@ reqwest = { version = "=0.12.22", default-features = false, features = [
|
||||
strip = true
|
||||
lto = "fat"
|
||||
codegen-units = 1
|
||||
panic = "abort"
|
||||
|
||||
+4
-4
@@ -25,8 +25,8 @@ pub async fn check_all(
|
||||
#[cfg(not(feature = "tui"))]
|
||||
tracing::info!("Started checking {} proxies", proxies.len());
|
||||
|
||||
let queue = Arc::new(tokio::sync::Mutex::new(proxies));
|
||||
let checked_proxies = Arc::new(tokio::sync::Mutex::new(Vec::new()));
|
||||
let queue = Arc::new(parking_lot::Mutex::new(proxies));
|
||||
let checked_proxies = Arc::new(parking_lot::Mutex::new(Vec::new()));
|
||||
|
||||
let mut join_set = tokio::task::JoinSet::<()>::new();
|
||||
for _ in 0..workers_count {
|
||||
@@ -41,7 +41,7 @@ pub async fn check_all(
|
||||
biased;
|
||||
res = async move {
|
||||
loop {
|
||||
let Some(mut proxy) = queue.lock().await.pop() else {
|
||||
let Some(mut proxy) = queue.lock().pop() else {
|
||||
break;
|
||||
};
|
||||
let check_result = proxy.check(&config).await;
|
||||
@@ -55,7 +55,7 @@ pub async fn check_all(
|
||||
drop(tx.send(Event::App(AppEvent::ProxyWorking(
|
||||
proxy.protocol,
|
||||
))));
|
||||
checked_proxies.lock().await.push(proxy);
|
||||
checked_proxies.lock().push(proxy);
|
||||
}
|
||||
Err(e)
|
||||
if tracing::event_enabled!(
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@ async fn scrape_one(
|
||||
config: Arc<Config>,
|
||||
http_client: reqwest::Client,
|
||||
proto: ProxyType,
|
||||
proxies: Arc<tokio::sync::Mutex<HashSet<Proxy>>>,
|
||||
proxies: Arc<parking_lot::Mutex<HashSet<Proxy>>>,
|
||||
source: Arc<Source>,
|
||||
#[cfg(feature = "tui")] tx: tokio::sync::mpsc::UnboundedSender<Event>,
|
||||
) -> color_eyre::Result<()> {
|
||||
@@ -73,7 +73,7 @@ async fn scrape_one(
|
||||
|
||||
#[cfg(feature = "tui")]
|
||||
let mut seen_protocols = HashSet::new();
|
||||
let mut proxies = proxies.lock().await;
|
||||
let mut proxies = proxies.lock();
|
||||
for capture in matches {
|
||||
let protocol = match capture.name("protocol") {
|
||||
Some(m) => m.as_str().parse()?,
|
||||
@@ -120,7 +120,7 @@ pub async fn scrape_all(
|
||||
token: tokio_util::sync::CancellationToken,
|
||||
#[cfg(feature = "tui")] tx: tokio::sync::mpsc::UnboundedSender<Event>,
|
||||
) -> color_eyre::Result<Vec<Proxy>> {
|
||||
let proxies = Arc::new(tokio::sync::Mutex::new(HashSet::new()));
|
||||
let proxies = Arc::new(parking_lot::Mutex::new(HashSet::new()));
|
||||
|
||||
let mut join_set = tokio::task::JoinSet::new();
|
||||
for (&proto, sources) in &config.scraping.sources {
|
||||
|
||||
Reference in New Issue
Block a user