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:18
/// ``` /// use std::sync::Arc; /// use tokio::sync::Semaphore; /// /// #[tokio::main] /// async fn main() { /// let semaphore = Arc::new(Semaphore::new(3)); /// let mut join_handles = Vec::new(); /// /// for _ in 0..5 { /// let permit = semaphore.clone().acqu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
0fbde0e94b06536917b6686e996856a33aeb29ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/semaphore.rs
681
740
tokio-rs/tokio:tokio/src/sync/semaphore.rs:19
Ok(OwnedSemaphorePermit { sem: self, permits: 1, }) } /// Acquires `n` permits 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
0fbde0e94b06536917b6686e996856a33aeb29ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/semaphore.rs
721
780
tokio-rs/tokio:tokio/src/sync/semaphore.rs:20
/// handle.await.unwrap(); /// } /// } /// ``` /// /// [`Arc`]: std::sync::Arc /// [`AcquireError`]: crate::sync::AcquireError /// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub async fn acquire_many_owned( self: Arc<Self>, n: u32, ) -> Re...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
0fbde0e94b06536917b6686e996856a33aeb29ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/semaphore.rs
761
820
tokio-rs/tokio:tokio/src/sync/semaphore.rs:23
/// ``` /// use tokio::sync::Semaphore; /// use std::sync::Arc; /// use tokio::sync::TryAcquireError; /// /// #[tokio::main] /// async fn main() { /// let semaphore = Arc::new(Semaphore::new(1)); /// let semaphore2 = semaphore.clone(); /// /// tokio::spawn(async move ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
0fbde0e94b06536917b6686e996856a33aeb29ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/semaphore.rs
881
940
tokio-rs/tokio:tokio/src/sync/semaphore.rs:24
/// Merge two [`SemaphorePermit`] instances together, consuming `other` /// without releasing the permits it holds. /// /// Permits held by both `self` and `other` are released when `self` drops. /// /// # Panics /// /// This function panics if permits from different [`Semaphore`] instances ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
0fbde0e94b06536917b6686e996856a33aeb29ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/semaphore.rs
921
980
tokio-rs/tokio:tokio/src/sync/semaphore.rs:25
assert!( Arc::ptr_eq(&self.sem, &other.sem), "merging permits from different semaphore instances" ); self.permits += other.permits; other.permits = 0; } /// Returns the [`Semaphore`] from which this permit was acquired. pub fn semaphore(&self) -> &Arc<Semapho...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
0fbde0e94b06536917b6686e996856a33aeb29ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/semaphore.rs
961
985
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12
/// /// [`tokio-console`]: https://github.com/tokio-rs/console /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new(permits: usize) -> Self { Self { ll_sem: ll::Semaphore::const_new(permits), #[cfg(all(tokio_unstable, feature...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
441
500
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
self.ll_sem.release(n); } /// Acquires a permit from the semaphore. /// /// If the semaphore has been closed, this returns an [`AcquireError`]. /// Otherwise, this returns a [`SemaphorePermit`] representing the /// acquired permit. /// /// # Cancel safety /// /// This method use...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
|| self.ll_sem.acquire(1), self.resource_span.clone(), "Semaphore::acquire", "poll", true, ); #[cfg(not(all(tokio_unstable, feature = "tracing")))] let inner = self.ll_sem.acquire(1); inner.await?; Ok(SemaphorePermit { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// ``` /// /// [`AcquireError`]: crate::sync::AcquireError /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub async fn acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] trace::async_op( || self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// /// let permit_2 = semaphore.try_acquire().unwrap(); /// assert_eq!(semaphore.available_permits(), 0); /// /// let permit_3 = semaphore.try_acquire(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`TryAcquireError::Closed`]: crate::syn...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:18
/// /// for _ in 0..5 { /// let permit = semaphore.clone().acquire_owned().await.unwrap(); /// join_handles.push(tokio::spawn(async move { /// // perform task... /// // explicitly own `permit` in the task /// drop(permit); /// }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
681
740
tokio-rs/tokio:tokio/src/sync/semaphore.rs:19
/// 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. /// /// # Cancel safety /// /// This method uses a queue t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
721
780
tokio-rs/tokio:tokio/src/sync/semaphore.rs:20
pub async fn acquire_many_owned( self: Arc<Self>, n: u32, ) -> Result<OwnedSemaphorePermit, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] let inner = trace::async_op( || self.ll_sem.acquire(n as usize), self.resource_span.clone(), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
761
820
tokio-rs/tokio:tokio/src/sync/semaphore.rs:21
/// assert_eq!(semaphore.available_permits(), 1); /// /// let permit_2 = Arc::clone(&semaphore).try_acquire_owned().unwrap(); /// assert_eq!(semaphore.available_permits(), 0); /// /// let permit_3 = semaphore.try_acquire_owned(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
801
860
tokio-rs/tokio:tokio/src/sync/semaphore.rs:22
/// /// let permit_1 = Arc::clone(&semaphore).try_acquire_many_owned(3).unwrap(); /// assert_eq!(semaphore.available_permits(), 1); /// /// let permit_2 = semaphore.try_acquire_many_owned(2); /// assert_eq!(permit_2.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
841
900
tokio-rs/tokio:tokio/src/sync/semaphore.rs:23
/// let semaphore2 = semaphore.clone(); /// /// tokio::spawn(async move { /// let permit = semaphore.acquire_many(2).await; /// assert!(permit.is_err()); /// println!("waiter received error"); /// }); /// /// println!("closing semaphore"); /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
881
940
tokio-rs/tokio:tokio/src/sync/semaphore.rs:24
/// This function panics if permits from different [`Semaphore`] instances /// are merged. #[track_caller] pub fn merge(&mut self, mut other: Self) { assert!( std::ptr::eq(self.sem, other.sem), "merging permits from different semaphore instances" ); self.permi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
921
977
tokio-rs/tokio:tokio/src/sync/semaphore.rs:25
/// Returns the [`Semaphore`] from which this permit was acquired. pub fn semaphore(&self) -> &Arc<Semaphore> { &self.sem } } impl Drop for SemaphorePermit<'_> { fn drop(&mut self) { self.sem.add_permits(self.permits as usize); } } impl Drop for OwnedSemaphorePermit { fn drop(&mut ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/semaphore.rs
961
977
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
|| self.ll_sem.acquire(1), self.resource_span.clone(), "Semaphore::acquire", "poll", true, ); #[cfg(not(all(tokio_unstable, feature = "tracing")))] let inner = self.ll_sem.acquire(1); inner.await?; Ok(SemaphorePermit { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7b555185ff9186f618b198126ee853980b187698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7b555185ff9186f618b198126ee853980b187698/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// ``` /// /// [`AcquireError`]: crate::sync::AcquireError /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub async fn acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] trace::async_op( || self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7b555185ff9186f618b198126ee853980b187698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7b555185ff9186f618b198126ee853980b187698/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// /// let permit_2 = semaphore.try_acquire().unwrap(); /// assert_eq!(semaphore.available_permits(), 0); /// /// let permit_3 = semaphore.try_acquire(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`TryAcquireError::Closed`]: crate::syn...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7b555185ff9186f618b198126ee853980b187698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7b555185ff9186f618b198126ee853980b187698/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:19
/// 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. /// /// # Cancel safety /// /// This method uses a queue t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7b555185ff9186f618b198126ee853980b187698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7b555185ff9186f618b198126ee853980b187698/tokio/src/sync/semaphore.rs
721
780
tokio-rs/tokio:tokio/src/sync/semaphore.rs:20
pub async fn acquire_many_owned( self: Arc<Self>, n: u32, ) -> Result<OwnedSemaphorePermit, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] let inner = trace::async_op( || self.ll_sem.acquire(n), self.resource_span.clone(), "Semaph...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7b555185ff9186f618b198126ee853980b187698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7b555185ff9186f618b198126ee853980b187698/tokio/src/sync/semaphore.rs
761
820
tokio-rs/tokio:tokio/src/sync/semaphore.rs:21
/// assert_eq!(semaphore.available_permits(), 1); /// /// let permit_2 = Arc::clone(&semaphore).try_acquire_owned().unwrap(); /// assert_eq!(semaphore.available_permits(), 0); /// /// let permit_3 = semaphore.try_acquire_owned(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7b555185ff9186f618b198126ee853980b187698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7b555185ff9186f618b198126ee853980b187698/tokio/src/sync/semaphore.rs
801
860
tokio-rs/tokio:tokio/src/sync/semaphore.rs:22
/// /// let permit_1 = Arc::clone(&semaphore).try_acquire_many_owned(3).unwrap(); /// assert_eq!(semaphore.available_permits(), 1); /// /// let permit_2 = semaphore.try_acquire_many_owned(2); /// assert_eq!(permit_2.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
7b555185ff9186f618b198126ee853980b187698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7b555185ff9186f618b198126ee853980b187698/tokio/src/sync/semaphore.rs
841
900
tokio-rs/tokio:tokio/src/sync/semaphore.rs:10
/// This type is created by the [`acquire_owned`] method. /// /// [`acquire_owned`]: crate::sync::Semaphore::acquire_owned() #[must_use] #[clippy::has_significant_drop] #[derive(Debug)] pub struct OwnedSemaphorePermit { sem: Arc<Semaphore>, permits: u32, } #[test] #[cfg(not(loom))] fn bounds() { fn check_u...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
361
420
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11
tracing::trace_span!( "runtime.resource", concrete_type = "Semaphore", kind = "Sync", loc.file = location.file(), loc.line = location.line(), loc.col = location.column(), inherits_child_attrs = true, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
401
460
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12
/// [`tokio-console`]: https://github.com/tokio-rs/console /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub const fn const_new(permits: usize) -> Self { Self { ll_sem: ll::Semaphore::const_new(permits), #[cfg(all(tokio_unstable, feature = "trac...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
441
500
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
} /// Acquires a permit from the semaphore. /// /// If the semaphore has been closed, this returns an [`AcquireError`]. /// Otherwise, this returns a [`SemaphorePermit`] representing the /// acquired permit. /// /// # Cancel safety /// /// This method uses a queue to fairly distribu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
self.resource_span.clone(), "Semaphore::acquire", "poll", true, ); #[cfg(not(all(tokio_unstable, feature = "tracing")))] let inner = self.ll_sem.acquire(1); inner.await?; Ok(SemaphorePermit { sem: self, permits: 1, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// /// [`AcquireError`]: crate::sync::AcquireError /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub async fn acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] trace::async_op( || self.ll_sem.acqui...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// let permit_2 = semaphore.try_acquire().unwrap(); /// assert_eq!(semaphore.available_permits(), 0); /// /// let permit_3 = semaphore.try_acquire(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`TryAcquireError::Closed`]: crate::sync::TryAc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:18
/// for _ in 0..5 { /// let permit = semaphore.clone().acquire_owned().await.unwrap(); /// join_handles.push(tokio::spawn(async move { /// // perform task... /// // explicitly own `permit` in the task /// drop(permit); /// })); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
681
740
tokio-rs/tokio:tokio/src/sync/semaphore.rs:19
/// If the semaphore has been closed, this returns an [`AcquireError`]. /// Otherwise, this returns a [`OwnedSemaphorePermit`] representing the /// acquired permit. /// /// # Cancel safety /// /// This method uses a queue to fairly distribute permits in the order they /// were requested. Can...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
721
780
tokio-rs/tokio:tokio/src/sync/semaphore.rs:20
self: Arc<Self>, n: u32, ) -> Result<OwnedSemaphorePermit, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] let inner = trace::async_op( || self.ll_sem.acquire(n), self.resource_span.clone(), "Semaphore::acquire_many_owned", "po...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
761
820
tokio-rs/tokio:tokio/src/sync/semaphore.rs:21
/// /// let permit_2 = Arc::clone(&semaphore).try_acquire_owned().unwrap(); /// assert_eq!(semaphore.available_permits(), 0); /// /// let permit_3 = semaphore.try_acquire_owned(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`Arc`]: std::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
801
860
tokio-rs/tokio:tokio/src/sync/semaphore.rs:22
/// let permit_1 = Arc::clone(&semaphore).try_acquire_many_owned(3).unwrap(); /// assert_eq!(semaphore.available_permits(), 1); /// /// let permit_2 = semaphore.try_acquire_many_owned(2); /// assert_eq!(permit_2.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`Arc`]: s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
841
900
tokio-rs/tokio:tokio/src/sync/semaphore.rs:23
/// /// tokio::spawn(async move { /// let permit = semaphore.acquire_many(2).await; /// assert!(permit.is_err()); /// println!("waiter received error"); /// }); /// /// println!("closing semaphore"); /// semaphore2.close(); /// /// // C...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
881
940
tokio-rs/tokio:tokio/src/sync/semaphore.rs:24
/// are merged. #[track_caller] pub fn merge(&mut self, mut other: Self) { assert!( std::ptr::eq(self.sem, other.sem), "merging permits from different semaphore instances" ); self.permits += other.permits; other.permits = 0; } } impl OwnedSemaphorePer...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
921
976
tokio-rs/tokio:tokio/src/sync/semaphore.rs:25
pub fn semaphore(&self) -> &Arc<Semaphore> { &self.sem } } impl 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
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/semaphore.rs
961
976
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// /// [`AcquireError`]: crate::sync::AcquireError /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub async fn acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] trace::async_op( || self.ll_sem.acqui...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d6ed00c292472d2aa75abd90321f0155141e06ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d6ed00c292472d2aa75abd90321f0155141e06ad/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// let permit_2 = semaphore.try_acquire().unwrap(); /// assert_eq!(semaphore.available_permits(), 0); /// /// let permit_3 = semaphore.try_acquire(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`TryAcquireError::Closed`]: crate::sync::TryAc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d6ed00c292472d2aa75abd90321f0155141e06ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d6ed00c292472d2aa75abd90321f0155141e06ad/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:20
self: Arc<Self>, n: u32, ) -> Result<OwnedSemaphorePermit, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] let inner = trace::async_op( || self.ll_sem.acquire(n), self.resource_span.clone(), "Semaphore::acquire_many_owned", "po...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d6ed00c292472d2aa75abd90321f0155141e06ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d6ed00c292472d2aa75abd90321f0155141e06ad/tokio/src/sync/semaphore.rs
761
820
tokio-rs/tokio:tokio/src/sync/semaphore.rs:21
/// /// let permit_2 = Arc::clone(&semaphore).try_acquire_owned().unwrap(); /// assert_eq!(semaphore.available_permits(), 0); /// /// let permit_3 = semaphore.try_acquire_owned(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`Arc`]: std::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d6ed00c292472d2aa75abd90321f0155141e06ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d6ed00c292472d2aa75abd90321f0155141e06ad/tokio/src/sync/semaphore.rs
801
860
tokio-rs/tokio:tokio/src/sync/semaphore.rs:22
/// let permit_1 = Arc::clone(&semaphore).try_acquire_many_owned(3).unwrap(); /// assert_eq!(semaphore.available_permits(), 1); /// /// let permit_2 = semaphore.try_acquire_many_owned(2); /// assert_eq!(permit_2.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`Arc`]: s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d6ed00c292472d2aa75abd90321f0155141e06ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d6ed00c292472d2aa75abd90321f0155141e06ad/tokio/src/sync/semaphore.rs
841
900
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9
/// } /// ``` /// /// [`PollSemaphore`]: https://docs.rs/tokio-util/latest/tokio_util/sync/struct.PollSemaphore.html /// [`Semaphore::acquire_owned`]: crate::sync::Semaphore::acquire_owned #[derive(Debug)] pub struct Semaphore { /// The low level semaphore ll_sem: ll::Semaphore, #[cfg(all(tokio_unstable, fe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
321
380
tokio-rs/tokio:tokio/src/sync/semaphore.rs:10
#[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 + Sync>() {} check_unpin::<Semaphore>(); check_unpin::<SemaphorePermit<'_>>(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
361
420
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11
#[cfg(all(tokio_unstable, feature = "tracing"))] let ll_sem = resource_span.in_scope(|| ll::Semaphore::new(permits)); #[cfg(any(not(tokio_unstable), not(feature = "tracing")))] let ll_sem = ll::Semaphore::new(permits); Self { ll_sem, #[cfg(all(tokio_unstable, fe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
401
460
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12
pub(crate) fn new_closed() -> Self { Self { ll_sem: ll::Semaphore::new_closed(), #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: tracing::Span::none(), } } /// Creates a new closed semaphore with 0 permits. #[cfg(not(all(loom, test)))] ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
441
500
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
/// in the queue. /// /// # Examples /// /// ``` /// use tokio::sync::Semaphore; /// /// #[tokio::main] /// async fn main() { /// let semaphore = Semaphore::new(2); /// /// let permit_1 = semaphore.acquire().await.unwrap(); /// assert_eq!(semaphore.available_p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
}) } /// Acquires `n` permits from the semaphore. /// /// If the semaphore has been closed, this returns an [`AcquireError`]. /// Otherwise, this returns a [`SemaphorePermit`] representing the /// acquired permits. /// /// # Cancel safety /// /// This method uses a queue to fair...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
.await?; #[cfg(not(all(tokio_unstable, feature = "tracing")))] self.ll_sem.acquire(n).await?; Ok(SemaphorePermit { sem: self, permits: n, }) } /// Tries to acquire a permit from the semaphore. /// /// If the semaphore has been closed, this retur...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
match self.ll_sem.try_acquire(1) { Ok(_) => Ok(SemaphorePermit { sem: self, permits: 1, }), Err(e) => Err(e), } } /// Tries to acquire `n` permits from the semaphore. /// /// If the semaphore has been closed, this returns a [`T...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17
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
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
641
700
tokio-rs/tokio:tokio/src/sync/semaphore.rs:18
/// } /// ``` /// /// [`Arc`]: std::sync::Arc /// [`AcquireError`]: crate::sync::AcquireError /// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub async fn acquire_owned(self: Arc<Self>) -> Result<OwnedSemaphorePermit, AcquireError> { #[cfg(all(tokio_unstable, feature = "t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
681
740
tokio-rs/tokio:tokio/src/sync/semaphore.rs:19
/// ``` /// use std::sync::Arc; /// use tokio::sync::Semaphore; /// /// #[tokio::main] /// async fn main() { /// let semaphore = Arc::new(Semaphore::new(10)); /// let mut join_handles = Vec::new(); /// /// for _ in 0..5 { /// let permit = semaphore.clone().acq...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
721
780
tokio-rs/tokio:tokio/src/sync/semaphore.rs:20
let inner = self.ll_sem.acquire(n); inner.await?; Ok(OwnedSemaphorePermit { sem: self, permits: n, }) } /// Tries to acquire a permit from the semaphore. /// /// The semaphore must be wrapped in an [`Arc`] to call this method. If /// the semaphore ha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
761
820
tokio-rs/tokio:tokio/src/sync/semaphore.rs:21
/// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub fn try_acquire_owned(self: Arc<Self>) -> Result<OwnedSemaphorePermit, TryAcquireError> { match self.ll_sem.try_acquire(1) { Ok(_) => Ok(OwnedSemaphorePermit { sem: self, permits: 1, })...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
801
860
tokio-rs/tokio:tokio/src/sync/semaphore.rs:22
pub fn try_acquire_many_owned( self: Arc<Self>, n: u32, ) -> Result<OwnedSemaphorePermit, TryAcquireError> { match self.ll_sem.try_acquire(n) { Ok(_) => Ok(OwnedSemaphorePermit { sem: self, permits: n, }), Err(e) => Err(e), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
841
900
tokio-rs/tokio:tokio/src/sync/semaphore.rs:23
/// } /// ``` pub fn close(&self) { 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. ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
881
940
tokio-rs/tokio:tokio/src/sync/semaphore.rs:24
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; } /// Merge two [`OwnedSemaphorePermit`] instances together...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
5d29136a8348ca13262295cc5bd7eb96d647ba65
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5d29136a8348ca13262295cc5bd7eb96d647ba65/tokio/src/sync/semaphore.rs
921
964
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
/// let capacity = 5; /// let update_interval = Duration::from_secs_f32(1.0 / capacity as f32); /// let bucket = TokenBucket::new(update_interval, capacity); /// /// for _ in 0..5 { /// bucket.acquire().await; /// /// // do the operation /// } /// } /// ``` /// /// [`PollSemaphore`]:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7
#[must_use] #[clippy::has_significant_drop] #[derive(Debug)] 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_v...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
241
300
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8
concrete_type = "Semaphore", kind = "Sync", loc.file = location.file(), loc.line = location.line(), loc.col = location.column(), inherits_child_attrs = true, ) }; #[cfg(all(tokio_unstable, feature = "tracing"))]...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
281
340
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9
pub const fn const_new(permits: usize) -> Self { Self { ll_sem: ll::Semaphore::const_new(permits), #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: tracing::Span::none(), } } /// Creates a new closed semaphore with 0 permits. pub(crate) fn ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
321
380
tokio-rs/tokio:tokio/src/sync/semaphore.rs:10
/// /// If the semaphore has been closed, this returns an [`AcquireError`]. /// Otherwise, this returns a [`SemaphorePermit`] representing the /// acquired permit. /// /// # Cancel safety /// /// This method uses a queue to fairly distribute permits in the order they /// were requested. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
361
420
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11
true, ); #[cfg(not(all(tokio_unstable, feature = "tracing")))] let inner = self.ll_sem.acquire(1); inner.await?; Ok(SemaphorePermit { sem: self, permits: 1, }) } /// Acquires `n` permits from the semaphore. /// /// If the semaphor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
401
460
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12
pub async fn acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] trace::async_op( || self.ll_sem.acquire(n), self.resource_span.clone(), "Semaphore::acquire_many", "poll", ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
441
500
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
/// let permit_3 = semaphore.try_acquire(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`TryAcquireError::Closed`]: crate::sync::TryAcquireError::Closed /// [`TryAcquireError::NoPermits`]: crate::sync::TryAcquireError::NoPermits /// [`SemaphoreP...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
/// [`TryAcquireError::Closed`]: crate::sync::TryAcquireError::Closed /// [`TryAcquireError::NoPermits`]: crate::sync::TryAcquireError::NoPermits /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub fn try_acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, TryAcquireError> { match self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// // perform task... /// // explicitly own `permit` in the task /// drop(permit); /// })); /// } /// /// for handle in join_handles { /// handle.await.unwrap(); /// } /// } /// ``` /// /// [`Arc`]: std::syn...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// /// # Cancel safety /// /// This method uses a queue to fairly distribute permits in the order they /// were requested. Cancelling a call to `acquire_many_owned` makes you lose /// your place in the queue. /// /// # Examples /// /// ``` /// use std::sync::Arc; /// use tok...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17
#[cfg(all(tokio_unstable, feature = "tracing"))] let inner = trace::async_op( || self.ll_sem.acquire(n), self.resource_span.clone(), "Semaphore::acquire_many_owned", "poll", true, ); #[cfg(not(all(tokio_unstable, feature = "tracing")))]...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
641
700
tokio-rs/tokio:tokio/src/sync/semaphore.rs:18
/// /// let permit_3 = semaphore.try_acquire_owned(); /// assert_eq!(permit_3.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`Arc`]: std::sync::Arc /// [`TryAcquireError::Closed`]: crate::sync::TryAcquireError::Closed /// [`TryAcquireError::NoPermits`]: crate::sync::T...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
681
740
tokio-rs/tokio:tokio/src/sync/semaphore.rs:19
/// let permit_2 = semaphore.try_acquire_many_owned(2); /// assert_eq!(permit_2.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`Arc`]: std::sync::Arc /// [`TryAcquireError::Closed`]: crate::sync::TryAcquireError::Closed /// [`TryAcquireError::NoPermits`]: crate::sync::Try...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
721
780
tokio-rs/tokio:tokio/src/sync/semaphore.rs:20
/// assert!(permit.is_err()); /// println!("waiter received error"); /// }); /// /// println!("closing semaphore"); /// semaphore2.close(); /// /// // Cannot obtain more permits /// assert_eq!(semaphore2.try_acquire().err(), Some(TryAcquireError::Close...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
761
820
tokio-rs/tokio:tokio/src/sync/semaphore.rs:21
assert!( std::ptr::eq(self.sem, other.sem), "merging permits from different semaphore instances" ); self.permits += other.permits; other.permits = 0; } } impl OwnedSemaphorePermit { /// Forgets the permit **without** releasing it back to the semaphore. /// Th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
801
853
tokio-rs/tokio:tokio/src/sync/semaphore.rs:22
} impl 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
02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/02aacf5110f8b9091489b1c0b6c254f7b8a9a6a4/tokio/src/sync/semaphore.rs
841
853
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
/// /// // do the operation /// } /// /// bucket.close().await; /// } /// ``` /// /// [`PollSemaphore`]: https://docs.rs/tokio-util/latest/tokio_util/sync/struct.PollSemaphore.html /// [`Semaphore::acquire_owned`]: crate::sync::Semaphore::acquire_owned #[derive(Debug)] pub struct Semaphore { /// The...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7
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 + Sync>() {} check_unpin::<Semaphor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
241
300
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8
loc.col = location.column(), inherits_child_attrs = true, ) }; #[cfg(all(tokio_unstable, feature = "tracing"))] let ll_sem = resource_span.in_scope(|| ll::Semaphore::new(permits)); #[cfg(any(not(tokio_unstable), not(feature = "tracing")))] let ll_sem...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
281
340
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9
resource_span: tracing::Span::none(), } } /// Creates a new closed semaphore with 0 permits. pub(crate) fn new_closed() -> Self { Self { ll_sem: ll::Semaphore::new_closed(), #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: tracing::Span::no...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
321
380
tokio-rs/tokio:tokio/src/sync/semaphore.rs:10
/// /// # Cancel safety /// /// This method uses a queue to fairly distribute permits in the order they /// were requested. Cancelling a call to `acquire` makes you lose your place /// in the queue. /// /// # Examples /// /// ``` /// use tokio::sync::Semaphore; /// /// #[...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
361
420
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11
inner.await?; Ok(SemaphorePermit { sem: self, permits: 1, }) } /// Acquires `n` permits from the semaphore. /// /// If the semaphore has been closed, this returns an [`AcquireError`]. /// Otherwise, this returns a [`SemaphorePermit`] representing the /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
401
460
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12
self.resource_span.clone(), "Semaphore::acquire_many", "poll", true, ) .await?; #[cfg(not(all(tokio_unstable, feature = "tracing")))] self.ll_sem.acquire(n).await?; Ok(SemaphorePermit { sem: self, permits: n, }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
441
500
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
/// /// [`TryAcquireError::Closed`]: crate::sync::TryAcquireError::Closed /// [`TryAcquireError::NoPermits`]: crate::sync::TryAcquireError::NoPermits /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub fn try_acquire(&self) -> Result<SemaphorePermit<'_>, TryAcquireError> { match self.ll_se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
match self.ll_sem.try_acquire(n) { Ok(_) => Ok(SemaphorePermit { sem: self, permits: n, }), Err(e) => Err(e), } } /// Acquires a permit from the semaphore. /// /// The semaphore must be wrapped in an [`Arc`] to call this method...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// } /// /// for handle in join_handles { /// handle.await.unwrap(); /// } /// } /// ``` /// /// [`Arc`]: std::sync::Arc /// [`AcquireError`]: crate::sync::AcquireError /// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub async fn acquire_o...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// were requested. Cancelling a call to `acquire_many_owned` makes you lose /// your place in the queue. /// /// # Examples /// /// ``` /// use std::sync::Arc; /// use tokio::sync::Semaphore; /// /// #[tokio::main] /// async fn main() { /// let semaphore = Arc::new(Semap...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17
"Semaphore::acquire_many_owned", "poll", true, ); #[cfg(not(all(tokio_unstable, feature = "tracing")))] let inner = self.ll_sem.acquire(n); inner.await?; Ok(OwnedSemaphorePermit { sem: self, permits: n, }) } /// Tr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
641
700
tokio-rs/tokio:tokio/src/sync/semaphore.rs:18
/// ``` /// /// [`Arc`]: std::sync::Arc /// [`TryAcquireError::Closed`]: crate::sync::TryAcquireError::Closed /// [`TryAcquireError::NoPermits`]: crate::sync::TryAcquireError::NoPermits /// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub fn try_acquire_owned(self: Arc<Self>) -> R...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
681
740
tokio-rs/tokio:tokio/src/sync/semaphore.rs:19
/// /// [`Arc`]: std::sync::Arc /// [`TryAcquireError::Closed`]: crate::sync::TryAcquireError::Closed /// [`TryAcquireError::NoPermits`]: crate::sync::TryAcquireError::NoPermits /// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub fn try_acquire_many_owned( self: Arc<Self>, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
721
780
tokio-rs/tokio:tokio/src/sync/semaphore.rs:20
/// println!("closing semaphore"); /// semaphore2.close(); /// /// // Cannot obtain more permits /// assert_eq!(semaphore2.try_acquire().err(), Some(TryAcquireError::Closed)) /// } /// ``` pub fn close(&self) { self.ll_sem.close(); } /// Returns true if the s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
761
820
tokio-rs/tokio:tokio/src/sync/semaphore.rs:21
self.permits += other.permits; other.permits = 0; } } 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; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
b161633b5f8aac105c0da5cc7a1008495794c528
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b161633b5f8aac105c0da5cc7a1008495794c528/tokio/src/sync/semaphore.rs
801
849
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
/// }); /// } /// } /// # async fn handle_connection(_socket: &mut tokio::net::TcpStream) { /// # // Do work /// # } /// ``` /// /// [`PollSemaphore`]: https://docs.rs/tokio-util/latest/tokio_util/sync/struct.PollSemaphore.html /// [`Semaphore::acquire_owned`]: crate::sync::Semaphore::acquire_owned #[deri...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
f5b8cf9dac1e153595036eb36ee214e5b6afb183
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f5b8cf9dac1e153595036eb36ee214e5b6afb183/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
/// # async fn handle_connection(_socket: &mut tokio::net::TcpStream) { /// # // Do work /// # } /// ``` /// /// [`PollSemaphore`]: https://docs.rs/tokio-util/latest/tokio_util/sync/struct.PollSemaphore.html /// [`Semaphore::acquire_owned`]: crate::sync::Semaphore::acquire_owned #[derive(Debug)] pub struct Semaphore ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
e6553c4ee3c5914cba885a6498451fcd0de3e506
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6553c4ee3c5914cba885a6498451fcd0de3e506/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5
#[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 + Sync>() {} check_unpin::<Semaphore>(); check_unpin::<SemaphorePermit<'_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
e6553c4ee3c5914cba885a6498451fcd0de3e506
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6553c4ee3c5914cba885a6498451fcd0de3e506/tokio/src/sync/semaphore.rs
161
220
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
}; #[cfg(all(tokio_unstable, feature = "tracing"))] let ll_sem = resource_span.in_scope(|| ll::Semaphore::new(permits)); #[cfg(any(not(tokio_unstable), not(feature = "tracing")))] let ll_sem = ll::Semaphore::new(permits); Self { ll_sem, #[cfg(all(tokio_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
e6553c4ee3c5914cba885a6498451fcd0de3e506
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6553c4ee3c5914cba885a6498451fcd0de3e506/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7
/// Creates a new closed semaphore with 0 permits. pub(crate) fn new_closed() -> Self { Self { ll_sem: ll::Semaphore::new_closed(), #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: tracing::Span::none(), } } /// Creates a new closed semapho...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
e6553c4ee3c5914cba885a6498451fcd0de3e506
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6553c4ee3c5914cba885a6498451fcd0de3e506/tokio/src/sync/semaphore.rs
241
300