Skip to content

refactor(semaphore): remove acquire-and-forget helpers - #175

Merged
tisonkun merged 1 commit into
mainfrom
codex/remove-acquire-and-forget
Aug 22, 2026
Merged

refactor(semaphore): remove acquire-and-forget helpers#175
tisonkun merged 1 commit into
mainfrom
codex/remove-acquire-and-forget

Conversation

@tisonkun

Copy link
Copy Markdown
Member

Summary

Remove these redundant convenience methods for 0.7:

  • Semaphore::try_acquire_and_forget
  • Semaphore::acquire_and_forget
  • Semaphore::try_acquire_owned_and_forget
  • Semaphore::acquire_owned_and_forget

Permit-level SemaphorePermit::forget and OwnedSemaphorePermit::forget remain unchanged. The changelog documents the migration.

Rationale

These helpers were introduced in #33 together with the public Semaphore::release_all API for an uncoupled acquire/release workflow. #34 removed release_all because it was a footgun, leaving four helpers that only compose existing operations.

The same behavior remains explicit through permit guards:

semaphore.acquire(n).await.forget();

if let Some(permit) = semaphore.try_acquire(n) {
    permit.forget();
}

This operation still uses the normal fair acquisition queue and remains cancellable while waiting. It is intentionally distinct from the immediate bounded drain_permits and exact reduce_permits operations clarified in #174. Expressing it as acquisition followed by permit-level forget preserves that distinction without four extra public methods.

Testing

  • cargo x lint
  • cargo x check
  • cargo x test --no-capture
  • cargo test --workspace --all-features

These helpers only compose permit acquisition with permit-level forget and add no independent semantics. Keep that operation explicit at the call site instead.

Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
tisonkun merged commit 8bd7c3b into main Aug 22, 2026
9 checks passed
@tisonkun
tisonkun deleted the codex/remove-acquire-and-forget branch August 22, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant