utils: replace defer, ContextGuard, DetachableTask with guarden crate (#2163)

This commit is contained in:
Luna Yao
2026-04-27 12:29:46 +02:00
committed by GitHub
parent 969ecfc4ca
commit d5c4700d32
17 changed files with 56 additions and 958 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ use std::{
use anyhow::Context;
use bytes::Bytes;
use dashmap::DashMap;
use guarden::defer;
use kcp_sys::{
endpoint::{ConnId, KcpEndpoint, KcpPacketReceiver},
ffi_safe::KcpConfig,
@@ -359,7 +360,7 @@ impl KcpProxyDst {
transport_type: TcpProxyEntryTransportType::Kcp.into(),
},
);
crate::defer! {
defer! {
proxy_entries.remove(&conn_id);
if proxy_entries.capacity() - proxy_entries.len() > 16 {
proxy_entries.shrink_to_fit();