Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Semaphore::is_closed method #3673

Merged
merged 2 commits into from Apr 4, 2021

Conversation

bikeshedder
Copy link
Contributor

Motivation

Right now the only way to check if a semaphore is closed is to do the following:

let is_closed = matches!(
    semaphore.try_acquire_many(0),
    Err(TryAcquireError::Closed)
);

It would be nice if I could just call semaphore.is_closed() instead.

Solution

Add a is_closed method to the public Semaphore API which calls the is_closed method of the underlying low level semaphore.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Apr 4, 2021
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

tokio/src/sync/semaphore.rs Outdated Show resolved Hide resolved
@Darksonn Darksonn merged commit b05b9a1 into tokio-rs:master Apr 4, 2021
@Darksonn Darksonn mentioned this pull request Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants