Skip to content

Commit b4e45b0

Browse files
committed
sync: rename local variable in Semaphore::poll_acquire
1 parent 74df9e7 commit b4e45b0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tokio/src/sync/batch_semaphore.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl Semaphore {
414414
} << Self::PERMIT_SHIFT;
415415

416416
let mut available = self.permits.load(Acquire);
417-
let mut acquired: usize;
417+
let mut acquired_shifted: usize;
418418

419419
// We could acquire the lock right now, but that's going to be
420420
// expensive. To optimize, we try once without holding the mutex
@@ -429,8 +429,8 @@ impl Semaphore {
429429
return Poll::Ready(Err(AcquireError::closed()));
430430
}
431431

432-
acquired = cmp::min(available, still_needed);
433-
let remaining = available - acquired;
432+
acquired_shifted = cmp::min(available, still_needed);
433+
let remaining = available - acquired_shifted;
434434

435435
// Not all permits were immediately available, so this waiter will
436436
// (probably) need to wait. We'll need to acquire a lock on the wait
@@ -439,7 +439,7 @@ impl Semaphore {
439439
// Otherwise, if we subtract the permits and then acquire the lock,
440440
// we might miss additional permits being added while waiting for
441441
// the lock.
442-
if acquired < still_needed && queue_guard.is_none() {
442+
if acquired_shifted < still_needed && queue_guard.is_none() {
443443
queue_guard = Some(self.waiters.lock());
444444
}
445445

@@ -458,19 +458,19 @@ impl Semaphore {
458458
self.resource_span.in_scope(|| {
459459
tracing::trace!(
460460
target: "runtime::resource::state_update",
461-
permits = (acquired >> Self::PERMIT_SHIFT),
461+
permits = (acquired_shifted >> Self::PERMIT_SHIFT),
462462
permits.op = "sub",
463463
);
464464
});
465465

466466
// If the waiter gets all the permits at the first try, don't bother
467467
// enqueuing it.
468-
if acquired == still_needed && !queued {
468+
if acquired_shifted == still_needed && !queued {
469469
#[cfg(all(tokio_unstable, feature = "tracing"))]
470470
self.resource_span.in_scope(|| {
471471
tracing::trace!(
472472
target: "runtime::resource::async_op::state_update",
473-
permits_obtained = (acquired >> Self::PERMIT_SHIFT),
473+
permits_obtained = (acquired_shifted >> Self::PERMIT_SHIFT),
474474
permits.op = "add",
475475
)
476476
});
@@ -482,7 +482,7 @@ impl Semaphore {
482482
return Poll::Ready(Err(AcquireError::closed()));
483483
}
484484

485-
acquired >>= Self::PERMIT_SHIFT;
485+
let mut acquired = acquired_shifted >> Self::PERMIT_SHIFT;
486486

487487
if node.assign_permits(&mut acquired) {
488488
// If the waiter is happy with the acquired permits, return the

0 commit comments

Comments
 (0)