use parking_lot::Mutex instead of tokio::sync::Mutex
This commit is contained in:
+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