id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | }
/// Returns the current number of available permits.
pub fn available_permits(&self) -> usize {
self.ll_sem.available_permits()
}
/// Adds `n` new permits to the semaphore.
///
/// The maximum number of permits is `usize::MAX >> 3`, and this function will panic if the limit is exceed... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | b05b9a1788e7b998609dae31016f2b338d6125f7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b05b9a1788e7b998609dae31016f2b338d6125f7/tokio/src/sync/semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4 | Ok(SemaphorePermit {
sem: &self,
permits: n,
})
}
/// Tries to acquire a permit from the semaphore.
///
/// If the semaphore has been closed, this returns a [`TryAcquireError::Closed`]
/// and a [`TryAcquireError::NoPermits`] if there are no permits left. Otherwise,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | b05b9a1788e7b998609dae31016f2b338d6125f7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b05b9a1788e7b998609dae31016f2b338d6125f7/tokio/src/sync/semaphore.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5 | Err(e) => Err(e),
}
}
/// Acquires a permit from the semaphore.
///
/// The semaphore must be wrapped in an [`Arc`] to call this method.
/// If the semaphore has been closed, this returns an [`AcquireError`].
/// Otherwise, this returns a [`OwnedSemaphorePermit`] representing the
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | b05b9a1788e7b998609dae31016f2b338d6125f7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b05b9a1788e7b998609dae31016f2b338d6125f7/tokio/src/sync/semaphore.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6 | })
}
/// Tries to acquire a permit from the semaphore.
///
/// The semaphore must be wrapped in an [`Arc`] to call this method. If
/// the semaphore has been closed, this returns a [`TryAcquireError::Closed`]
/// and a [`TryAcquireError::NoPermits`] if there are no permits left.
/// Otherwi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | b05b9a1788e7b998609dae31016f2b338d6125f7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b05b9a1788e7b998609dae31016f2b338d6125f7/tokio/src/sync/semaphore.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7 | ) -> Result<OwnedSemaphorePermit, TryAcquireError> {
match self.ll_sem.try_acquire(n) {
Ok(_) => Ok(OwnedSemaphorePermit {
sem: self,
permits: n,
}),
Err(e) => Err(e),
}
}
/// Closes the semaphore.
///
/// This prevents... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | b05b9a1788e7b998609dae31016f2b338d6125f7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b05b9a1788e7b998609dae31016f2b338d6125f7/tokio/src/sync/semaphore.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8 | self.ll_sem.close();
}
/// Returns true if the semaphore is closed
pub fn is_closed(&self) -> bool {
self.ll_sem.is_closed()
}
}
impl<'a> SemaphorePermit<'a> {
/// Forgets the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits av... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | b05b9a1788e7b998609dae31016f2b338d6125f7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b05b9a1788e7b998609dae31016f2b338d6125f7/tokio/src/sync/semaphore.rs | 281 | 318 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7 | ) -> Result<OwnedSemaphorePermit, TryAcquireError> {
match self.ll_sem.try_acquire(n) {
Ok(_) => Ok(OwnedSemaphorePermit {
sem: self,
permits: n,
}),
Err(e) => Err(e),
}
}
/// Closes the semaphore.
///
/// This prevents... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | fc23f8a1a50aa4a3df47cf81d3ae51213b7e6d71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc23f8a1a50aa4a3df47cf81d3ae51213b7e6d71/tokio/src/sync/semaphore.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8 | self.ll_sem.close();
}
}
impl<'a> SemaphorePermit<'a> {
/// Forgets the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits available from a
/// semaphore.
pub fn forget(mut self) {
self.permits = 0;
}
}
impl OwnedSemaphorePermit ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | fc23f8a1a50aa4a3df47cf81d3ae51213b7e6d71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc23f8a1a50aa4a3df47cf81d3ae51213b7e6d71/tokio/src/sync/semaphore.rs | 281 | 313 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4 | Ok(SemaphorePermit {
sem: &self,
permits: n,
})
}
/// Tries to acquire a permit from the semaphore.
///
/// If the semaphore has been closed, this returns a [`TryAcquireError::Closed`]
/// and a [`TryAcquireError::NoPermits`] if there are no permits left. Otherwise,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 29bd5fad5ca0100b4b72bda350b0f7bf37e86127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29bd5fad5ca0100b4b72bda350b0f7bf37e86127/tokio/src/sync/semaphore.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5 | Err(e) => Err(e),
}
}
/// Acquires a permit from the semaphore.
///
/// The semaphore must be wrapped in an [`Arc`] to call this method.
/// If the semaphore has been closed, this returns an [`AcquireError`].
/// Otherwise, this returns a [`OwnedSemaphorePermit`] representing the
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 29bd5fad5ca0100b4b72bda350b0f7bf37e86127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29bd5fad5ca0100b4b72bda350b0f7bf37e86127/tokio/src/sync/semaphore.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6 | Err(e) => Err(e),
}
}
/// Closes the semaphore.
///
/// This prevents the semaphore from issuing new permits and notifies all pending waiters.
///
/// # Examples
///
/// ```
/// use tokio::sync::Semaphore;
/// use std::sync::Arc;
/// use tokio::sync::TryAcquireError;... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 29bd5fad5ca0100b4b72bda350b0f7bf37e86127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29bd5fad5ca0100b4b72bda350b0f7bf37e86127/tokio/src/sync/semaphore.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7 | /// This can be used to reduce the amount of permits available from a
/// semaphore.
pub fn forget(mut self) {
self.permits = 0;
}
}
impl OwnedSemaphorePermit {
/// Forgets the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits availa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 29bd5fad5ca0100b4b72bda350b0f7bf37e86127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/29bd5fad5ca0100b4b72bda350b0f7bf37e86127/tokio/src/sync/semaphore.rs | 241 | 267 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | use super::batch_semaphore as ll; // low level implementation
use super::{AcquireError, TryAcquireError};
use std::sync::Arc;
/// Counting semaphore performing asynchronous permit acquisition.
///
/// A semaphore maintains a set of permits. Permits are used to synchronize
/// access to a shared resource. A semaphore d... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | fcce78b33ad67d0910f01ba4a2e79e5197e97aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcce78b33ad67d0910f01ba4a2e79e5197e97aab/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | pub struct OwnedSemaphorePermit {
sem: Arc<Semaphore>,
permits: u32,
}
#[test]
#[cfg(not(loom))]
fn bounds() {
fn check_unpin<T: Unpin>() {}
// This has to take a value, since the async fn's return type is unnameable.
fn check_send_sync_val<T: Send + Sync>(_t: T) {}
fn check_send_sync<T: Send +... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | fcce78b33ad67d0910f01ba4a2e79e5197e97aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcce78b33ad67d0910f01ba4a2e79e5197e97aab/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | }
/// Adds `n` new permits to the semaphore.
///
/// The maximum number of permits is `usize::MAX >> 3`, and this function will panic if the limit is exceeded.
pub fn add_permits(&self, n: usize) {
self.ll_sem.release(n);
}
/// Acquires a permit from the semaphore.
///
/// If t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | fcce78b33ad67d0910f01ba4a2e79e5197e97aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcce78b33ad67d0910f01ba4a2e79e5197e97aab/tokio/src/sync/semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4 | /// Tries to acquire a permit from the semaphore.
///
/// If the semaphore has been closed, this returns a [`TryAcquireError::Closed`]
/// and a [`TryAcquireError::NoPermits`] if there are no permits left. Otherwise,
/// this returns a [`SemaphorePermit`] representing the acquired permits.
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | fcce78b33ad67d0910f01ba4a2e79e5197e97aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcce78b33ad67d0910f01ba4a2e79e5197e97aab/tokio/src/sync/semaphore.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5 | ///
/// The semaphore must be wrapped in an [`Arc`] to call this method.
/// If the semaphore has been closed, this returns an [`AcquireError`].
/// Otherwise, this returns a [`OwnedSemaphorePermit`] representing the
/// acquired permit.
///
/// [`Arc`]: std::sync::Arc
/// [`AcquireError`]: ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | fcce78b33ad67d0910f01ba4a2e79e5197e97aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcce78b33ad67d0910f01ba4a2e79e5197e97aab/tokio/src/sync/semaphore.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6 | ///
/// This prevents the semaphore from issuing new permits and notifies all pending waiters.
///
/// # Examples
///
/// ```
/// use tokio::sync::Semaphore;
/// use std::sync::Arc;
/// use tokio::sync::TryAcquireError;
///
/// #[tokio::main]
/// async fn main() {
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | fcce78b33ad67d0910f01ba4a2e79e5197e97aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcce78b33ad67d0910f01ba4a2e79e5197e97aab/tokio/src/sync/semaphore.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7 | }
impl OwnedSemaphorePermit {
/// Forgets the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits available from a
/// semaphore.
pub fn forget(mut self) {
self.permits = 0;
}
}
impl<'a> Drop for SemaphorePermit<'_> {
fn drop(&mut... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | fcce78b33ad67d0910f01ba4a2e79e5197e97aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcce78b33ad67d0910f01ba4a2e79e5197e97aab/tokio/src/sync/semaphore.rs | 241 | 262 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | use super::batch_semaphore as ll; // low level implementation
use std::sync::Arc;
/// Counting semaphore performing asynchronous permit acquisition.
///
/// A semaphore maintains a set of permits. Permits are used to synchronize
/// access to a shared resource. A semaphore differs from a mutex in that it
/// can allow... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a52f5071bf5ecf31c44e8aba5d8611400c50eb71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a52f5071bf5ecf31c44e8aba5d8611400c50eb71/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | sem: Arc<Semaphore>,
permits: u32,
}
/// Error returned from the [`Semaphore::try_acquire`] function.
///
/// A `try_acquire` operation can only fail if the semaphore has no available
/// permits.
///
/// [`Semaphore::try_acquire`]: Semaphore::try_acquire
#[derive(Debug)]
pub struct TryAcquireError(());
#[test]
#... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a52f5071bf5ecf31c44e8aba5d8611400c50eb71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a52f5071bf5ecf31c44e8aba5d8611400c50eb71/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | Self {
ll_sem: ll::Semaphore::const_new(permits),
}
}
/// Returns the current number of available permits.
pub fn available_permits(&self) -> usize {
self.ll_sem.available_permits()
}
/// Adds `n` new permits to the semaphore.
///
/// The maximum number of permi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a52f5071bf5ecf31c44e8aba5d8611400c50eb71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a52f5071bf5ecf31c44e8aba5d8611400c50eb71/tokio/src/sync/semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4 | permits: 1,
}),
Err(_) => Err(TryAcquireError(())),
}
}
/// Tries to acquire `n` permits from the semaphore.
pub fn try_acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, TryAcquireError> {
match self.ll_sem.try_acquire(n) {
Ok(_) => Ok(SemaphoreP... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a52f5071bf5ecf31c44e8aba5d8611400c50eb71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a52f5071bf5ecf31c44e8aba5d8611400c50eb71/tokio/src/sync/semaphore.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5 | }),
Err(_) => Err(TryAcquireError(())),
}
}
}
impl<'a> SemaphorePermit<'a> {
/// Forgets the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits available from a
/// semaphore.
pub fn forget(mut self) {
self.permits... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a52f5071bf5ecf31c44e8aba5d8611400c50eb71 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a52f5071bf5ecf31c44e8aba5d8611400c50eb71/tokio/src/sync/semaphore.rs | 161 | 195 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | use super::batch_semaphore as ll; // low level implementation
use std::sync::Arc;
/// Counting semaphore performing asynchronous permit acquisition.
///
/// A semaphore maintains a set of permits. Permits are used to synchronize
/// access to a shared resource. A semaphore differs from a mutex in that it
/// can allow... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 43d071489837a154dd56b42176c637b635e1891f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/43d071489837a154dd56b42176c637b635e1891f/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | sem: Arc<Semaphore>,
permits: u16,
}
/// Error returned from the [`Semaphore::try_acquire`] function.
///
/// A `try_acquire` operation can only fail if the semaphore has no available
/// permits.
///
/// [`Semaphore::try_acquire`]: Semaphore::try_acquire
#[derive(Debug)]
pub struct TryAcquireError(());
#[test]
#... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 43d071489837a154dd56b42176c637b635e1891f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/43d071489837a154dd56b42176c637b635e1891f/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | Self {
ll_sem: ll::Semaphore::const_new(permits),
}
}
/// Returns the current number of available permits.
pub fn available_permits(&self) -> usize {
self.ll_sem.available_permits()
}
/// Adds `n` new permits to the semaphore.
///
/// The maximum number of permi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 43d071489837a154dd56b42176c637b635e1891f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/43d071489837a154dd56b42176c637b635e1891f/tokio/src/sync/semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4 | ///
/// [`Arc`]: std::sync::Arc
pub async fn acquire_owned(self: Arc<Self>) -> OwnedSemaphorePermit {
self.ll_sem.acquire(1).await.unwrap();
OwnedSemaphorePermit {
sem: self,
permits: 1,
}
}
/// Tries to acquire a permit from the semaphore.
///
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 43d071489837a154dd56b42176c637b635e1891f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/43d071489837a154dd56b42176c637b635e1891f/tokio/src/sync/semaphore.rs | 121 | 175 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5 | self.permits = 0;
}
}
impl<'a> Drop for SemaphorePermit<'_> {
fn drop(&mut self) {
self.sem.add_permits(self.permits as usize);
}
}
impl Drop for OwnedSemaphorePermit {
fn drop(&mut self) {
self.sem.add_permits(self.permits as usize);
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 43d071489837a154dd56b42176c637b635e1891f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/43d071489837a154dd56b42176c637b635e1891f/tokio/src/sync/semaphore.rs | 161 | 175 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | Self {
ll_sem: ll::Semaphore::const_new(permits),
}
}
/// Returns the current number of available permits.
pub fn available_permits(&self) -> usize {
self.ll_sem.available_permits()
}
/// Adds `n` new permits to the semaphore.
///
/// The maximum number of permi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4 | ///
/// [`Arc`]: std::sync::Arc
pub async fn acquire_owned(self: Arc<Self>) -> OwnedSemaphorePermit {
self.ll_sem.acquire(1).await.unwrap();
OwnedSemaphorePermit {
sem: self.clone(),
permits: 1,
}
}
/// Tries to acquire a permit from the semaphore.
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore.rs | 121 | 175 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | use super::batch_semaphore as ll; // low level implementation
use std::sync::Arc;
/// Counting semaphore performing asynchronous permit aquisition.
///
/// A semaphore maintains a set of permits. Permits are used to synchronize
/// access to a shared resource. A semaphore differs from a mutex in that it
/// can allow ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8d2e3bc575f51815ae7319f1e43fe6c7d664e6e4/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | sem: Arc<Semaphore>,
permits: u16,
}
/// Error returned from the [`Semaphore::try_acquire`] function.
///
/// A `try_acquire` operation can only fail if the semaphore has no available
/// permits.
///
/// [`Semaphore::try_acquire`]: Semaphore::try_acquire
#[derive(Debug)]
pub struct TryAcquireError(());
#[test]
#... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a5c1a7de0399625792b476666ea1326cb8bcd75c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a5c1a7de0399625792b476666ea1326cb8bcd75c/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | /// Adds `n` new permits to the semaphore.
///
/// The maximum number of permits is `usize::MAX >> 3`, and this function will panic if the limit is exceeded.
pub fn add_permits(&self, n: usize) {
self.ll_sem.release(n);
}
/// Acquires permit from the semaphore.
pub async fn acquire(&sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a5c1a7de0399625792b476666ea1326cb8bcd75c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a5c1a7de0399625792b476666ea1326cb8bcd75c/tokio/src/sync/semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4 | /// Tries to acquire a permit from the semaphore.
///
/// The semaphore must be wrapped in an [`Arc`] to call this method.
///
/// [`Arc`]: std::sync::Arc
pub fn try_acquire_owned(self: Arc<Self>) -> Result<OwnedSemaphorePermit, TryAcquireError> {
match self.ll_sem.try_acquire(1) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a5c1a7de0399625792b476666ea1326cb8bcd75c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a5c1a7de0399625792b476666ea1326cb8bcd75c/tokio/src/sync/semaphore.rs | 121 | 166 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | sem: Arc<Semaphore>,
permits: u16,
}
/// Error returned from the [`Semaphore::try_acquire`] function.
///
/// A `try_acquire` operation can only fail if the semaphore has no available
/// permits.
///
/// [`Semaphore::try_acquire`]: Semaphore::try_acquire
#[derive(Debug)]
pub struct TryAcquireError(());
#[test]
#... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 4748b2571fc02d5ebbfe59e457f0e8d8ef0eb5f3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4748b2571fc02d5ebbfe59e457f0e8d8ef0eb5f3/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | /// Adds `n` new permits to the semaphore.
pub fn add_permits(&self, n: usize) {
self.ll_sem.release(n);
}
/// Acquires permit from the semaphore.
pub async fn acquire(&self) -> SemaphorePermit<'_> {
self.ll_sem.acquire(1).await.unwrap();
SemaphorePermit {
sem: &self... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 4748b2571fc02d5ebbfe59e457f0e8d8ef0eb5f3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4748b2571fc02d5ebbfe59e457f0e8d8ef0eb5f3/tokio/src/sync/semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4 | ///
/// The semaphore must be wrapped in an [`Arc`] to call this method.
///
/// [`Arc`]: std::sync::Arc
pub fn try_acquire_owned(self: Arc<Self>) -> Result<OwnedSemaphorePermit, TryAcquireError> {
match self.ll_sem.try_acquire(1) {
Ok(_) => Ok(OwnedSemaphorePermit {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 4748b2571fc02d5ebbfe59e457f0e8d8ef0eb5f3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4748b2571fc02d5ebbfe59e457f0e8d8ef0eb5f3/tokio/src/sync/semaphore.rs | 121 | 164 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | use super::batch_semaphore as ll; // low level implementation
use crate::coop::CoopFutureExt;
use std::sync::Arc;
/// Counting semaphore performing asynchronous permit aquisition.
///
/// A semaphore maintains a set of permits. Permits are used to synchronize
/// access to a shared resource. A semaphore differs from a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 5a548044d7bfd5d1c59d1a398d34ccbc29cbfe70 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a548044d7bfd5d1c59d1a398d34ccbc29cbfe70/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | pub struct OwnedSemaphorePermit {
sem: Arc<Semaphore>,
permits: u16,
}
/// Error returned from the [`Semaphore::try_acquire`] function.
///
/// A `try_acquire` operation can only fail if the semaphore has no available
/// permits.
///
/// [`Semaphore::try_acquire`]: Semaphore::try_acquire
#[derive(Debug)]
pub ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 5a548044d7bfd5d1c59d1a398d34ccbc29cbfe70 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a548044d7bfd5d1c59d1a398d34ccbc29cbfe70/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | }
/// Adds `n` new permits to the semaphore.
pub fn add_permits(&self, n: usize) {
self.ll_sem.release(n);
}
/// Acquires permit from the semaphore.
pub async fn acquire(&self) -> SemaphorePermit<'_> {
self.ll_sem.acquire(1).cooperate().await.unwrap();
SemaphorePermit {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 5a548044d7bfd5d1c59d1a398d34ccbc29cbfe70 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a548044d7bfd5d1c59d1a398d34ccbc29cbfe70/tokio/src/sync/semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | use super::batch_semaphore as ll; // low level implementation
use crate::coop::CoopFutureExt;
/// Counting semaphore performing asynchronous permit aquisition.
///
/// A semaphore maintains a set of permits. Permits are used to synchronize
/// access to a shared resource. A semaphore differs from a mutex in that it
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 1121a8eb23f6f0edd9f41cdc08331d40e18105ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1121a8eb23f6f0edd9f41cdc08331d40e18105ee/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | fn check_unpin<T: Unpin>() {}
// This has to take a value, since the async fn's return type is unnameable.
fn check_send_sync_val<T: Send + Sync>(_t: T) {}
fn check_send_sync<T: Send + Sync>() {}
check_unpin::<Semaphore>();
check_unpin::<SemaphorePermit<'_>>();
check_send_sync::<Semaphore>();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 1121a8eb23f6f0edd9f41cdc08331d40e18105ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1121a8eb23f6f0edd9f41cdc08331d40e18105ee/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | pub fn try_acquire(&self) -> Result<SemaphorePermit<'_>, TryAcquireError> {
match self.ll_sem.try_acquire(1) {
Ok(_) => Ok(SemaphorePermit {
sem: self,
permits: 1,
}),
Err(_) => Err(TryAcquireError(())),
}
}
}
impl<'a> SemaphorePer... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 1121a8eb23f6f0edd9f41cdc08331d40e18105ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1121a8eb23f6f0edd9f41cdc08331d40e18105ee/tokio/src/sync/semaphore.rs | 81 | 105 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | use super::batch_semaphore as ll; // low level implementation
use crate::coop::CoopFutureExt;
/// Counting semaphore performing asynchronous permit aquisition.
///
/// A semaphore maintains a set of permits. Permits are used to synchronize
/// access to a shared resource. A semaphore differs from a mutex in that it
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | fn check_unpin<T: Unpin>() {}
check_unpin::<Semaphore>();
check_unpin::<SemaphorePermit<'_>>();
}
impl Semaphore {
/// Creates a new semaphore with the initial number of permits
pub fn new(permits: usize) -> Self {
Self {
ll_sem: ll::Semaphore::new(permits),
}
}
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/semaphore.rs | 41 | 98 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | }
}
}
impl<'a> SemaphorePermit<'a> {
/// Forgets the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits available from a
/// semaphore.
pub fn forget(mut self) {
self.permits = 0;
}
}
impl<'a> Drop for SemaphorePermit<'_> {
f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/semaphore.rs | 81 | 98 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | use super::semaphore_ll as ll; // low level implementation
use crate::future::poll_fn;
/// Counting semaphore performing asynchronous permit aquisition.
///
/// A semaphore maintains a set of permits. Permits are used to synchronize
/// access to a shared resource. A semaphore differs from a mutex in that it
/// can a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 06a4d895ec8787386058a24b422dfa9a8514bc8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | pub fn new(permits: usize) -> Self {
Self {
ll_sem: ll::Semaphore::new(permits),
}
}
/// Returns the current number of available permits
pub fn available_permits(&self) -> usize {
self.ll_sem.available_permits()
}
/// Adds `n` new permits to the semaphore.
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 06a4d895ec8787386058a24b422dfa9a8514bc8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | }),
Err(_) => Err(TryAcquireError(())),
}
}
}
impl<'a> SemaphorePermit<'a> {
/// Forgets the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits available from a
/// semaphore.
pub fn forget(mut self) {
self.ll_perm... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 06a4d895ec8787386058a24b422dfa9a8514bc8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/sync/semaphore.rs | 81 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | pub fn new(permits: usize) -> Self {
Self {
ll_sem: ll::Semaphore::new(permits),
}
}
/// Returns the current number of available permits
pub fn available_permits(&self) -> usize {
self.ll_sem.available_permits()
}
/// Adds `n` new permits to the semaphore.
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/semaphore.rs | 41 | 95 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | impl<'a> SemaphorePermit<'a> {
/// Forgets the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits available from a
/// semaphore.
pub fn forget(mut self) {
self.ll_permit.forget(1);
}
}
impl<'a> Drop for SemaphorePermit<'_> {
fn d... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/semaphore.rs | 81 | 95 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | use super::semaphore_ll as ll; // low level implementation
use crate::future::poll_fn;
/// Counting semaphore performing asynchronous permit aquisition.
///
/// A semaphore maintains a set of permits. Permits are used to synchronize
/// access to a shared resource. A semaphore differs from a mutex in that it
/// can a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | efcbf9613f2d5048550f9c828e3be422644f1391 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/efcbf9613f2d5048550f9c828e3be422644f1391/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | pub fn new(permits: usize) -> Self {
Self {
ll_sem: ll::Semaphore::new(permits),
}
}
/// Returns the current number of available permits
pub fn available_permits(&self) -> usize {
self.ll_sem.available_permits()
}
/// Add `n` new permits to the semaphore.
pu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | efcbf9613f2d5048550f9c828e3be422644f1391 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/efcbf9613f2d5048550f9c828e3be422644f1391/tokio/src/sync/semaphore.rs | 41 | 95 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | impl<'a> SemaphorePermit<'a> {
/// Forget the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits available from a
/// semaphore.
pub fn forget(mut self) {
self.ll_permit.forget(1);
}
}
impl<'a> Drop for SemaphorePermit<'_> {
fn dr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | efcbf9613f2d5048550f9c828e3be422644f1391 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/efcbf9613f2d5048550f9c828e3be422644f1391/tokio/src/sync/semaphore.rs | 81 | 95 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | pub fn new(permits: usize) -> Self {
Self {
ll_sem: ll::Semaphore::new(permits),
}
}
/// Returns the current number of available permits
pub fn available_permits(&self) -> usize {
self.ll_sem.available_permits()
}
/// Add `n` new permits to the semaphore.
pu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 8656b7b8eb6f3635ec40694eb71f14fb84211e05 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8656b7b8eb6f3635ec40694eb71f14fb84211e05/tokio/src/sync/semaphore.rs | 41 | 95 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | impl<'a> SemaphorePermit<'a> {
/// Forget the permit **without** releasing it back to the semaphore.
/// This can be used to reduce the amount of permits available from a
/// semaphore.
pub fn forget(mut self) {
self.ll_permit.forget();
}
}
impl<'a> Drop for SemaphorePermit<'_> {
fn dro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 8656b7b8eb6f3635ec40694eb71f14fb84211e05 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8656b7b8eb6f3635ec40694eb71f14fb84211e05/tokio/src/sync/semaphore.rs | 81 | 95 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | pub fn new(permits: usize) -> Self {
Self {
ll_sem: ll::Semaphore::new(permits),
}
}
/// Returns the current number of available permits
pub fn available_permits(&self) -> usize {
self.ll_sem.available_permits()
}
/// Add `n` new permits to the semaphore.
pu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 9211adbe01661585cd1831214279262024d04816 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore.rs | 41 | 91 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | /// semaphore.
pub fn forget(mut self) {
self.ll_permit.forget();
}
}
impl<'a> Drop for SemaphorePermit<'_> {
fn drop(&mut self) {
self.ll_permit.release(&self.sem.ll_sem);
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 9211adbe01661585cd1831214279262024d04816 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/semaphore.rs | 81 | 91 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | stub: Box<WaiterNode>,
}
/// A semaphore permit
///
/// Tracks the lifecycle of a semaphore permit.
///
/// An instance of `Permit` is intended to be used with a **single** instance of
/// `Semaphore`. Using a single instance of `Permit` with multiple semaphore
/// instances will result in unexpected behavior.
///
///... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:1 | //! Thread-safe, asynchronous counting semaphore.
//!
//! A `Semaphore` instance holds a set of permits. Permits are used to
//! synchronize access to a shared resource.
//!
//! Before accessing the shared resource, callers acquire a permit from the
//! semaphore. Once the permit is acquired, the caller then enters the... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2 | /// A semaphore permit
///
/// Tracks the lifecycle of a semaphore permit.
///
/// An instance of `Permit` is intended to be used with a **single** instance of
/// `Semaphore`. Using a single instance of `Permit` with multiple semaphore
/// instances will result in unexpected behavior.
///
/// `Permit` does **not** rel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3 | state: AtomicUsize,
/// Task to wake when a permit is made available.
waker: AtomicWaker,
/// Next pointer in the queue of waiting senders.
next: AtomicPtr<WaiterNode>,
}
/// Semaphore state
///
/// The 2 low bits track the modes.
///
/// - Closed
/// - Full
///
/// When not full, the rest of the `us... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4 | /// Not waiting for a permit and the node is not in the wait queue.
///
/// This is the initial state.
Idle = 0,
/// Not waiting for a permit but the node is in the wait queue.
///
/// This happens when the waiter has previously requested a permit, but has
/// since canceled the request. Th... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5 | Semaphore {
state: AtomicUsize::new(state.to_usize()),
head: CausalCell::new(ptr),
rx_lock: AtomicUsize::new(0),
stub,
}
}
/// Returns the current number of available permits
pub fn available_permits(&self) -> usize {
let curr = SemState::load... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6 | };
}
loop {
let mut next = curr;
if curr.is_closed() {
undo_strong!();
return Ready(Err(AcquireError::closed()));
}
if !next.acquire_permit(&self.stub) {
debug!(" + poll_permit -- no permits");
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7 | }
next.set_waiter(maybe_strong.unwrap());
}
debug!(" + poll_permit -- pre-CAS; next = {:?}", next);
debug_assert_ne!(curr.0, 0);
debug_assert_ne!(next.0, 0);
match next.compare_exchange(&self.state, curr, AcqRel, Acquire) {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8 | }
/// Close the semaphore. This prevents the semaphore from issuing new
/// permits and notifies all pending waiters.
pub fn close(&self) {
debug!("+ Semaphore::close");
// Acquire the `rx_lock`, setting the "closed" flag on the lock.
let prev = self.rx_lock.fetch_or(1, AcqRel);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9 | self.add_permits_locked(n, false);
}
fn add_permits_locked(&self, mut rem: usize, mut closed: bool) {
while rem > 0 || closed {
debug!(
" + add_permits_locked -- iter; rem = {}; closed = {:?}",
rem, closed
);
if closed {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:10 | rem = (actual >> 1) - rem;
}
debug!(" + add_permits; done");
}
/// Release a specific amount of permits to the semaphore
///
/// This function is called by `add_permits` after the add lock has been
/// acquired.
fn add_permits_locked2(&self, mut n: usize, closed: bool) {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11 | let stub = self.stub();
if head == stub {
debug!(" + pop; head == stub");
let next = match NonNull::new(next_ptr) {
Some(next) => next,
None => {
// This loop is not part of the standard... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12 | if rem == 0 {
debug_assert!(curr.is_closed(), "state = {:?}", curr);
return None;
}
let mut next = curr;
next.release_permits(rem, &self.stub);
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13 | continue 'outer;
}
self.push_stub(closed);
next_ptr = head.as_ref().next.load(Acquire);
if let Some(next) = NonNull::new(next_ptr) {
self.head.with_mut(|head| *head = next);
return Some(Arc::from_raw(head.as_ptr(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14 | debug_assert_ne!(prev, stub);
// Release `task` to the consume end.
prev.as_ref().next.store(stub.as_ptr(), Release);
}
fn stub(&self) -> NonNull<WaiterNode> {
unsafe { NonNull::new_unchecked(&*self.stub as *const _ as *mut _) }
}
}
impl fmt::Debug for Semaphore {
fn fmt(&self... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15 | pub fn new() -> Permit {
Permit {
waiter: None,
state: PermitState::Idle,
}
}
/// Returns true if the permit has been acquired
pub fn is_acquired(&self) -> bool {
self.state == PermitState::Acquired
}
/// Try to acquire the permit. If no permits are ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16 | }
Pending => {
self.state = PermitState::Waiting;
Pending
}
}
}
/// Try to acquire the permit.
pub fn try_acquire(&mut self, semaphore: &Semaphore) -> Result<(), TryAcquireError> {
match self.state {
PermitState::Idle => {}... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17 | }
}
/// Forget the permit **without** releasing it back to the semaphore.
///
/// After calling `forget`, `poll_acquire` is able to acquire new permit
/// from the sempahore.
///
/// Repeatedly calling `forget` without associated calls to `add_permit`
/// will result in the semaphore lo... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:18 | fn closed() -> AcquireError {
AcquireError(())
}
}
fn to_try_acquire(_: AcquireError) -> TryAcquireError {
TryAcquireError::closed()
}
impl fmt::Display for AcquireError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "semaphore closed")
}
}
impl ::std::erro... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:19 | /// Returns true if the error was caused by calling `try_acquire` on a
/// semaphore with no available permits.
pub fn is_no_permits(&self) -> bool {
match self.kind {
ErrorKind::NoPermits => true,
_ => false,
}
}
}
impl fmt::Display for TryAcquireError {
fn fmt(... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:20 | self.acquire2()
}
fn acquire2(&self) -> Result<bool, AcquireError> {
use self::NodeState::*;
match Idle.compare_exchange(&self.state, Assigned, AcqRel, Acquire) {
Ok(_) => Ok(true),
Err(Closed) => Err(AcquireError::closed()),
Err(_) => Ok(false),
}
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:21 | }
}
/// Transition the state to `QueuedWaiting`.
///
/// This step can only happen from `Queued` or from `Idle`.
///
/// Returns `true` if transitioning into a queued state.
fn to_queued_waiting(&self) -> bool {
use self::NodeState::*;
let mut curr = NodeState::load(&self.s... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:22 | // Assume QueuedWaiting state
let mut curr = QueuedWaiting;
loop {
let next = match curr {
Queued => Idle,
QueuedWaiting => {
if closed {
Closed
} else {
Assigned
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:23 | #[allow(clippy::wrong_self_convention)] // https://github.com/rust-lang/rust-clippy/issues/4293
fn into_non_null(self: Arc<WaiterNode>) -> NonNull<WaiterNode> {
let ptr = Arc::into_raw(self);
unsafe { NonNull::new_unchecked(ptr as *mut _) }
}
}
// ===== impl State =====
/// Flag differentiatin... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:24 | if closed {
val |= CLOSED_FLAG;
}
SemState(val)
}
/// Returns the amount of remaining capacity
fn available_permits(self) -> usize {
if !self.has_available_permits() {
return 0;
}
self.0 >> NUM_SHIFT
}
/// Returns true if the state ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:25 | if self.0 == NUM_FLAG {
// Set the state to the stub pointer.
self.0 = stub as *const _ as usize;
}
true
}
/// Release permits
///
/// Returns `true` if the permits were accepted.
fn release_permits(&mut self, permits: usize, stub: &WaiterNode) {
deb... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:26 | /// Assumes `self` represents a pointer
fn as_ptr(self) -> *mut WaiterNode {
(self.0 & !CLOSED_FLAG) as *mut WaiterNode
}
/// Set to a pointer to a waiter.
///
/// This can only be done from the full state.
fn set_waiter(&mut self, waiter: NonNull<WaiterNode>) {
let waiter = wai... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:27 | failure: Ordering,
) -> Result<SemState, SemState> {
debug_assert_eq!(prev.is_closed(), self.is_closed());
let res = cell.compare_exchange(prev.to_usize(), self.to_usize(), success, failure);
debug!(
" + SemState::compare_exchange; prev = {}; next = {}; result = {:?}",
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:28 | fmt.finish()
}
}
// ===== impl NodeState =====
impl NodeState {
fn new() -> NodeState {
NodeState::Idle
}
fn from_usize(value: usize) -> NodeState {
use self::NodeState::*;
match value {
0 => Idle,
1 => Queued,
2 => QueuedWaiting,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/semaphore.rs:29 | ) -> Result<NodeState, NodeState> {
cell.compare_exchange(prev.to_usize(), self.to_usize(), success, failure)
.map(NodeState::from_usize)
.map_err(NodeState::from_usize)
}
/// Returns `true` if `self` represents a queued state.
fn is_queued(self) -> bool {
use self::... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/semaphore.rs | 1,121 | 1,140 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:1 | #![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))]
//! Thread-safe, asynchronous counting semaphore.
//!
//! A `Semaphore` instance holds a set of permits. Permits are used to
//! synchronize access to a shared resource.
//!
//! Before accessing the shared resource, callers acquire a permit from th... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:2 | /// A semaphore permit
///
/// Tracks the lifecycle of a semaphore permit.
///
/// An instance of `Permit` is intended to be used with a **single** instance of
/// `Semaphore`. Using a single instance of `Permit` with multiple semaphore
/// instances will result in unexpected behavior.
///
/// `Permit` does **not** rel... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:3 | /// Next pointer in the queue of waiting senders.
next: AtomicPtr<Waiter>,
}
/// Semaphore state
///
/// The 2 low bits track the modes.
///
/// - Closed
/// - Full
///
/// When not full, the rest of the `usize` tracks the total number of messages
/// in the channel. When full, the rest of the `usize` is a pointer... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:4 | /// Represents "one requested permit" in the waiter state
const PERMIT_ONE: usize = 0b1000;
/// Masks the waiter state to only contain bits tracking number of requested
/// permits.
const PERMIT_MASK: usize = usize::MAX - (PERMIT_ONE - 1);
/// How much to shift a permit count to pack it into the waker state
const PER... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:5 | // Allocations are aligned
debug_assert!(ptr.as_ptr() as usize & NUM_FLAG == 0);
let state = SemState::new(permits, &stub);
Semaphore {
state: AtomicUsize::new(state.to_usize()),
head: UnsafeCell::new(ptr),
rx_lock: AtomicUsize::new(0),
stub,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:6 | }
}
/// Polls for a permit
///
/// Tries to acquire available permits first. If unable to acquire a
/// sufficient number of permits, the caller's waiter is pushed onto the
/// semaphore's wait queue.
fn poll_acquire2<F>(
&self,
num_permits: u16,
mut get_waiter: F,
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:7 | revert_to_idle!();
return Ready(Err(AcquireError::closed()));
}
let acquired = next.acquire_permits(num_permits, &self.stub);
if !acquired {
// There are not enough available permits to satisfy the
// request. The permit transitions t... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:8 | debug_assert_ne!(curr.0, 0);
debug_assert_ne!(next.0, 0);
match self.state.compare_exchange(curr.0, next.0, AcqRel, Acquire) {
Ok(_) => {
if acquired {
// Successfully acquire permits **without** queuing the
// ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:9 | /// Closes the semaphore. This prevents the semaphore from issuing new
/// permits and notifies all pending waiters.
pub(crate) fn close(&self) {
// Acquire the `rx_lock`, setting the "closed" flag on the lock.
let prev = self.rx_lock.fetch_or(1, AcqRel);
if prev != 0 {
// A... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:10 | }
// Release the permits and notify
self.add_permits_locked2(rem, closed);
let n = rem << 1;
let actual = if closed {
let actual = self.rx_lock.fetch_sub(n | 1, AcqRel);
closed = false;
actual
} else {
... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/semaphore_ll.rs:11 | // The stub node indicates an empty queue. Any remaining
// permits get assigned back to the semaphore.
let next = match NonNull::new(next_ptr) {
Some(next) => next,
None => {
// This loop is not part of ... | rust | rust | macro-heavy | tokio-rs/tokio | tokio/src/sync/semaphore_ll.rs | MIT | 3fd043931e6d37f211e682980edc6e12e9d4fc54 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3fd043931e6d37f211e682980edc6e12e9d4fc54/tokio/src/sync/semaphore_ll.rs | 401 | 460 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.