summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/batch_semaphore.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio/src/sync/batch_semaphore.rs')
-rw-r--r--tokio/src/sync/batch_semaphore.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/tokio/src/sync/batch_semaphore.rs b/tokio/src/sync/batch_semaphore.rs
index 436737a6..698e908e 100644
--- a/tokio/src/sync/batch_semaphore.rs
+++ b/tokio/src/sync/batch_semaphore.rs
@@ -386,7 +386,11 @@ impl Future for Acquire<'_> {
type Output = Result<(), AcquireError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
+ // First, ensure the current task has enough budget to proceed.
+ ready!(crate::coop::poll_proceed(cx));
+
let (node, semaphore, needed, queued) = self.project();
+
match semaphore.poll_acquire(cx, needed, node, *queued) {
Pending => {
*queued = true;