pub async fn acquire(&self) -> SemaphorePermit<P> {
        // We need to clone the underlying semaphore so it is both owned by the
        // current object and the Tokio permit. This way it is safe to drop the
        // ObservableCountingSemaphore object before the permit, although not
        // recommended.
        let sem_for_permit = Arc::clone(&self.semaphore);
        // Can't panic because the semaphore is never closed before this call.
        let permit = sem_for_permit
            .acquire_owned()
            .await
            .expect("Acquiring a permit on closed semaphore. This can't happen.");
        self.gauge.inc();
        SemaphorePermit {
            gauge: self.gauge.clone(),
            _permit: permit,
        }
    }
/// A call to acquire will return a permit that will be valid until being
/// dropped. Please note the semantics of acquire is different from the
/// semantics of `tokio::sync::Semaphore::{acquire,acquire_owned}`.
///
/// 1. Unlike in Tokio when acquire_owned is used, the
/// `ObservableCountingSemaphore` doesn't need to be wrapped in Arc.
/// Furthermore, if you want to reuse the semaphore you don't need to clone
/// it before hand in order to retain ownership.
///
/// 2. Unlike in Tokio when acquire is used, you can pass the
/// permit across different threads without worrying about lifetimes.
A call to acquire will return a permit that will be valid until being
dropped.

1. Unlike in Tokio when acquire_owned is used, the
`ObservableCountingSemaphore` doesn't need to be wrapped in Arc.
Furthermore, if you want to reuse the semaphore you don't need to clone
it before hand in order to retain ownership.

2. Unlike in Tokio when acquire is used, you can pass the
permit across different threads without worrying about lifetimes.
A call to acquire will return a permit that will be valid until being dropped . 1 . Unlike in Tokio when acquire_owned is used the ` ObservableCountingSemaphore ` doesn ' t need to be wrapped in Arc . Furthermore if you want to reuse the semaphore you don ' t need to clone it before hand in order to retain ownership . 2 . Unlike in Tokio when acquire is used you can pass the permit across different threads without worrying about lifetimes .
pub async fn acquire(&self) -> SemaphorePermit<P> {
        // We need to clone the underlying semaphore so it is both owned by the
        // current object and the Tokio permit. This way it is safe to drop the
        // ObservableCountingSemaphore object before the permit, although not
        // recommended.
        let sem_for_permit = Arc::clone(&self.semaphore);
        // Can't panic because the semaphore is never closed before this call.
        let permit = sem_for_permit
            .acquire_owned()
            .await
            .expect("Acquiring a permit on closed semaphore. This can't happen.");
        self.gauge.inc();
        SemaphorePermit {
            gauge: self.gauge.clone(),
            _permit: permit,
        }
    }
pub async fn acquire ( & self ) -> SemaphorePermit < P > { // We need to clone the underlying semaphore so it is both owned by the // current object and the Tokio permit. This way it is safe to drop the // ObservableCountingSemaphore object before the permit, although not // recommended. let sem_for_permit = Arc :: clone ( & self . semaphore ) ; // Can't panic because the semaphore is never closed before this call. let permit = sem_for_permit . acquire_owned ( ) . await . expect ( " " ) ; self . gauge . inc ( ) ; SemaphorePermit { gauge : self . gauge . clone ( ) , _permit : permit , } }
A call to acquire will return a permit that will be valid until being
dropped.
A call to acquire will return a permit that will be valid until being dropped .
&self
&self