Skip to content

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!

@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.

2 participants