Skip to content

Commit 1e9874b

Browse files
committed
remove active handle
1 parent d8c8559 commit 1e9874b

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

crates/trie/parallel/src/proof_task.rs

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ use reth_trie_db::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
5252
use reth_trie_sparse::provider::{RevealedNode, TrieNodeProvider, TrieNodeProviderFactory};
5353
use std::{
5454
sync::{
55-
atomic::{AtomicUsize, Ordering},
5655
mpsc::{channel, Receiver, Sender},
5756
Arc,
5857
},
@@ -839,14 +838,12 @@ impl ProofTaskCtx {
839838
/// The handle stores direct senders to both storage and account worker pools,
840839
/// eliminating the need for a routing thread. All handles share reference-counted
841840
/// channels, and workers shut down gracefully when all handles are dropped.
842-
#[derive(Debug)]
841+
#[derive(Debug, Clone)]
843842
pub struct ProofTaskManagerHandle {
844843
/// Direct sender to storage worker pool
845844
storage_work_tx: CrossbeamSender<StorageWorkerJob>,
846845
/// Direct sender to account worker pool
847846
account_work_tx: CrossbeamSender<AccountWorkerJob>,
848-
/// Active handle reference count for auto-termination
849-
active_handles: Arc<AtomicUsize>,
850847
}
851848

852849
impl ProofTaskManagerHandle {
@@ -937,7 +934,7 @@ impl ProofTaskManagerHandle {
937934
);
938935
}
939936

940-
Ok(Self::new_handle(storage_work_tx, account_work_tx, Arc::new(AtomicUsize::new(0))))
937+
Ok(Self::new_handle(storage_work_tx, account_work_tx))
941938
}
942939

943940
/// Creates a new [`ProofTaskManagerHandle`] with direct access to worker pools.
@@ -946,10 +943,8 @@ impl ProofTaskManagerHandle {
946943
fn new_handle(
947944
storage_work_tx: CrossbeamSender<StorageWorkerJob>,
948945
account_work_tx: CrossbeamSender<AccountWorkerJob>,
949-
active_handles: Arc<AtomicUsize>,
950946
) -> Self {
951-
active_handles.fetch_add(1, Ordering::SeqCst);
952-
Self { storage_work_tx, account_work_tx, active_handles }
947+
Self { storage_work_tx, account_work_tx }
953948
}
954949

955950
/// Queue a storage proof computation
@@ -1014,31 +1009,6 @@ impl ProofTaskManagerHandle {
10141009
}
10151010
}
10161011

1017-
impl Clone for ProofTaskManagerHandle {
1018-
fn clone(&self) -> Self {
1019-
Self::new_handle(
1020-
self.storage_work_tx.clone(),
1021-
self.account_work_tx.clone(),
1022-
self.active_handles.clone(),
1023-
)
1024-
}
1025-
}
1026-
1027-
impl Drop for ProofTaskManagerHandle {
1028-
fn drop(&mut self) {
1029-
// Decrement the number of active handles.
1030-
// When the last handle is dropped, the channels are dropped and workers shut down.
1031-
// atomically grab the current handle count and decrement it for Drop.
1032-
let previous_handles = self.active_handles.fetch_sub(1, Ordering::SeqCst);
1033-
1034-
debug_assert_ne!(
1035-
previous_handles, 0,
1036-
"active_handles underflow in ProofTaskManagerHandle::drop (previous={})",
1037-
previous_handles
1038-
);
1039-
}
1040-
}
1041-
10421012
impl TrieNodeProviderFactory for ProofTaskManagerHandle {
10431013
type AccountNodeProvider = ProofTaskTrieNodeProvider;
10441014
type StorageNodeProvider = ProofTaskTrieNodeProvider;

0 commit comments

Comments
 (0)