Skip to content

Commit

Permalink
Improve usage of atomic counter
Browse files Browse the repository at this point in the history
Use load instead of fetch_add when obtaining and compairing the value of mempool's verification tasks counter
  • Loading branch information
viquezclaudio committed Apr 22, 2024
1 parent ae6fc60 commit 427b1c7
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions mempool/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ impl<N: Network, T: Topic + Unpin + Sync> Future for MempoolExecutor<N, T> {

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
while let Some((tx, pubsub_id)) = ready!(self.txn_stream.as_mut().poll_next_unpin(cx)) {
if self.verification_tasks.fetch_add(0, AtomicOrdering::SeqCst)
>= CONCURRENT_VERIF_TASKS
{
if self.verification_tasks.load(AtomicOrdering::SeqCst) >= CONCURRENT_VERIF_TASKS {
log::debug!("Reached the max number of verification tasks");
continue;
}
Expand Down

0 comments on commit 427b1c7

Please sign in to comment.