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:8
/// 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; /// /// #[tokio::main] /// async fn main() { ...
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
281
340
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9
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 /// acquired permits. /// /// # Cancel safety /...
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
321
380
tokio-rs/tokio:tokio/src/sync/semaphore.rs:10
true, ) .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...
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
361
420
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11
/// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub fn try_acquire(&self) -> Result<SemaphorePermit<'_>, TryAcquireError> { match self.ll_sem.try_acquire(1) { Ok(_) => Ok(SemaphorePermit { sem: self, permits: 1, }), Err(e) => Err(e), ...
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
401
460
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12
permits: n, }), 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 [`OwnedS...
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
441
500
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
/// handle.await.unwrap(); /// } /// } /// ``` /// /// [`Arc`]: std::sync::Arc /// [`AcquireError`]: crate::sync::AcquireError /// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub async fn acquire_owned(self: Arc<Self>) -> Result<OwnedSemaphorePermit, AcquireEr...
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
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
/// # Examples /// /// ``` /// 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 per...
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
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
); #[cfg(not(all(tokio_unstable, feature = "tracing")))] 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 ...
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
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// [`TryAcquireError::Closed`]: crate::sync::TryAcquireError::Closed /// [`TryAcquireError::NoPermits`]: crate::sync::TryAcquireError::NoPermits /// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub fn try_acquire_owned(self: Arc<Self>) -> Result<OwnedSemaphorePermit, TryAcquireError> { ...
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
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17
/// [`TryAcquireError::NoPermits`]: crate::sync::TryAcquireError::NoPermits /// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub fn try_acquire_many_owned( self: Arc<Self>, n: u32, ) -> Result<OwnedSemaphorePermit, TryAcquireError> { match self.ll_sem.try_acquire(n) { ...
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
641
700
tokio-rs/tokio:tokio/src/sync/semaphore.rs:18
/// // 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 semaphore is closed pub fn is_closed(&self) -> bool { self.ll_sem.is_clo...
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
681
740
tokio-rs/tokio:tokio/src/sync/semaphore.rs:19
} 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 toget...
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
721
766
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3
/// program attempts to open a large number of files and exceeds this /// limit, it will result in an error. /// /// This example uses a Semaphore with 100 permits. By acquiring a permit from /// the Semaphore before accessing a file, you ensure that your program opens /// no more than 100 files at a time. When trying ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
81
140
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
#[clippy::has_significant_drop] #[derive(Debug)] pub struct SemaphorePermit<'a> { sem: &'a Semaphore, permits: u32, } /// An owned permit from the semaphore. /// /// This type is created by the [`acquire_owned`] method. /// /// [`acquire_owned`]: crate::sync::Semaphore::acquire_owned() #[must_use] #[clippy::ha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5
/// Creates a new semaphore with the initial number of permits. /// /// Panics if `permits` exceeds [`Semaphore::MAX_PERMITS`]. #[track_caller] pub fn new(permits: usize) -> Self { #[cfg(all(tokio_unstable, feature = "tracing"))] let resource_span = { let location = std::pani...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
161
220
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
/// /// # Examples /// /// ``` /// use tokio::sync::Semaphore; /// /// static SEM: Semaphore = Semaphore::const_new(10); /// ``` /// /// [`tokio-console`]: https://github.com/tokio-rs/console /// [unstable feature]: crate#unstable-features #[cfg(not(all(loom, test)))] pub...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7
pub fn available_permits(&self) -> usize { self.ll_sem.available_permits() } /// Adds `n` new permits to the semaphore. /// /// The maximum number of permits is [`Semaphore::MAX_PERMITS`], and this function will panic if the limit is exceeded. pub fn add_permits(&self, n: usize) { s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
241
300
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8
/// } /// ``` /// /// [`AcquireError`]: crate::sync::AcquireError /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub async fn acquire(&self) -> Result<SemaphorePermit<'_>, AcquireError> { #[cfg(all(tokio_unstable, feature = "tracing"))] let inner = trace::async_op( ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
281
340
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9
/// /// #[tokio::main] /// async fn main() { /// let semaphore = Semaphore::new(5); /// /// let permit = semaphore.acquire_many(3).await.unwrap(); /// assert_eq!(semaphore.available_permits(), 2); /// } /// ``` /// /// [`AcquireError`]: crate::sync::AcquireError /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
321
380
tokio-rs/tokio:tokio/src/sync/semaphore.rs:10
/// ``` /// use tokio::sync::{Semaphore, TryAcquireError}; /// /// # fn main() { /// let semaphore = Semaphore::new(2); /// /// let permit_1 = semaphore.try_acquire().unwrap(); /// assert_eq!(semaphore.available_permits(), 1); /// /// let permit_2 = semaphore.try_acquire().unwrap(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
361
420
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
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
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
/// 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
d247e7f5df4bd861287467ecc5f827538bee4d63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d247e7f5df4bd861287467ecc5f827538bee4d63/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5
/// Creates a new semaphore with the initial number of permits. /// /// Panics if `permits` exceeds [`Semaphore::MAX_PERMITS`]. #[track_caller] pub fn new(permits: usize) -> Self { #[cfg(all(tokio_unstable, feature = "tracing"))] let resource_span = { let location = std::pani...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
8955ed5f8525d3585d99e762452978edb69a73ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/semaphore.rs
161
220
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
/// /// static SEM: Semaphore = Semaphore::const_new(10); /// ``` #[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 = "tracing"))] resource_span: tr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
8955ed5f8525d3585d99e762452978edb69a73ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9
/// ``` /// /// [`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
8955ed5f8525d3585d99e762452978edb69a73ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/semaphore.rs
321
380
tokio-rs/tokio:tokio/src/sync/semaphore.rs:10
/// /// 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
8955ed5f8525d3585d99e762452978edb69a73ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/semaphore.rs
361
420
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
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
8955ed5f8525d3585d99e762452978edb69a73ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// 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
8955ed5f8525d3585d99e762452978edb69a73ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// /// 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
8955ed5f8525d3585d99e762452978edb69a73ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
/// /// static SEM: Semaphore = Semaphore::const_new(10); /// ``` #[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 = "tracing"))] resource_span: tr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7
/// /// 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; /// /// #[tokio::main] /// async fn ma...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
241
300
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8
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 /// acquired permits. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
281
340
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9
"poll", true, ) .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. /// /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
321
380
tokio-rs/tokio:tokio/src/sync/semaphore.rs:10
/// [`TryAcquireError::NoPermits`]: crate::sync::TryAcquireError::NoPermits /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub fn try_acquire(&self) -> Result<SemaphorePermit<'_>, TryAcquireError> { match self.ll_sem.try_acquire(1) { Ok(_) => Ok(SemaphorePermit { sem: ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
361
420
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11
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. /// If the semaphore has been closed, this returns an [`AcquireError`]. /// Otherwi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
401
460
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12
/// for handle in join_handles { /// handle.await.unwrap(); /// } /// } /// ``` /// /// [`Arc`]: std::sync::Arc /// [`AcquireError`]: crate::sync::AcquireError /// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub async fn acquire_owned(self: Arc<Self>) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
441
500
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
/// /// # Examples /// /// ``` /// 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 { /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
true, ); #[cfg(not(all(tokio_unstable, feature = "tracing")))] let inner = self.ll_sem.acquire(n); inner.await?; Ok(OwnedSemaphorePermit { sem: self, permits: n, }) } /// Tries to acquire a permit from the semaphore. /// /// The s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// [`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>) -> Result<OwnedSemaphore...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// [`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>, n: u32, ) -> Result<OwnedSemap...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17
/// /// // 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 semaphore is closed pub fn is_closed(&self) -> bool { self.ll_se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
641
700
tokio-rs/tokio:tokio/src/sync/semaphore.rs:18
} } 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 tog...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
bc26934e3bedd3b46dd406622a95e1ea14c03be0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bc26934e3bedd3b46dd406622a95e1ea14c03be0/tokio/src/sync/semaphore.rs
681
727
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3
ll_sem: ll::Semaphore, #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: tracing::Span, } /// A permit from the semaphore. /// /// This type is created by the [`acquire`] method. /// /// [`acquire`]: crate::sync::Semaphore::acquire() #[must_use] #[clippy::has_significant_drop] #[derive(Debug)] pu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
81
140
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
check_send_sync::<Semaphore>(); let semaphore = Semaphore::new(0); check_send_sync_val(semaphore.acquire()); } impl Semaphore { /// The maximum number of permits which a semaphore can hold. It is `usize::MAX >> 3`. /// /// Exceeding this limit typically results in a panic. pub const MAX_PERMIT...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5
#[cfg(all(tokio_unstable, feature = "tracing"))] resource_span, } } /// Creates a new semaphore with the initial number of permits. /// /// # Examples /// /// ``` /// use tokio::sync::Semaphore; /// /// static SEM: Semaphore = Semaphore::const_new(10); /// ``...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
161
220
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
pub fn add_permits(&self, n: usize) { 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. /// /// #...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7
let inner = trace::async_op( || 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?; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
241
300
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8
/// } /// ``` /// /// [`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( ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
281
340
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9
/// assert_eq!(semaphore.available_permits(), 1); /// /// 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)); /// # } /// ``` ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
321
380
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11
/// let mut join_handles = Vec::new(); /// /// 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
401
460
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12
/// /// 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
441
500
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
/// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit 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.acq...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
/// let permit_1 = Arc::clone(&semaphore).try_acquire_owned().unwrap(); /// 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_own...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// let semaphore = Arc::new(Semaphore::new(4)); /// /// 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::No...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// let semaphore = Arc::new(Semaphore::new(1)); /// let semaphore2 = semaphore.clone(); /// /// tokio::spawn(async move { /// let permit = semaphore.acquire_many(2).await; /// assert!(permit.is_err()); /// println!("waiter received error"); /// }); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17
/// /// 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" ); se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
efe3ab679a05f3da3fcc511a44120239830254f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/efe3ab679a05f3da3fcc511a44120239830254f2/tokio/src/sync/semaphore.rs
641
698
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
check_send_sync::<Semaphore>(); let semaphore = Semaphore::new(0); check_send_sync_val(semaphore.acquire()); } impl Semaphore { /// The maximum number of permits which a semaphore can hold. It is `usize::MAX >> 3`. /// /// Exceeding this limit typically results in a panic. pub const MAX_PERMIT...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
a883fd437821fb3019ea2f100d1feade607f4cb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a883fd437821fb3019ea2f100d1feade607f4cb4/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5
#[cfg(all(tokio_unstable, feature = "tracing"))] resource_span, } } /// Creates a new semaphore with the initial number of permits. /// /// # Examples /// /// ``` /// use tokio::sync::Semaphore; /// /// static SEM: Semaphore = Semaphore::const_new(10); /// ``...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
a883fd437821fb3019ea2f100d1feade607f4cb4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a883fd437821fb3019ea2f100d1feade607f4cb4/tokio/src/sync/semaphore.rs
161
220
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3
ll_sem: ll::Semaphore, #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: tracing::Span, } /// A permit from the semaphore. /// /// This type is created by the [`acquire`] method. /// /// [`acquire`]: crate::sync::Semaphore::acquire() #[must_use] #[clippy::has_significant_drop] #[derive(Debug)] pu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
3b16564ce01008b58fecf95aef910fd596054152
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b16564ce01008b58fecf95aef910fd596054152/tokio/src/sync/semaphore.rs
81
140
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
check_send_sync::<Semaphore>(); let semaphore = Semaphore::new(0); check_send_sync_val(semaphore.acquire()); } impl Semaphore { /// The maximum number of permits which a semaphore can hold. It is `usize::MAX >>> 3`. /// /// Exceeding this limit typically results in a panic. pub const MAX_PERMI...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
3b16564ce01008b58fecf95aef910fd596054152
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b16564ce01008b58fecf95aef910fd596054152/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17
/// 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
d6dbefcdc043da552615bf2c8ad1f3a9580a1735
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/semaphore.rs
641
691
tokio-rs/tokio:tokio/src/sync/semaphore.rs:18
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
d6dbefcdc043da552615bf2c8ad1f3a9580a1735
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/semaphore.rs
681
691
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3
ll_sem: ll::Semaphore, #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: tracing::Span, } /// A permit from the semaphore. /// /// This type is created by the [`acquire`] method. /// /// [`acquire`]: crate::sync::Semaphore::acquire() #[must_use] #[derive(Debug)] pub struct SemaphorePermit<'a> { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
81
140
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
let semaphore = Semaphore::new(0); check_send_sync_val(semaphore.acquire()); } impl Semaphore { /// The maximum number of permits which a semaphore can hold. It is `usize::MAX >>> 3`. /// /// Exceeding this limit typically results in a panic. pub const MAX_PERMITS: usize = super::batch_semaphore::S...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5
} } /// Creates a new semaphore with the initial number of permits. /// /// # Examples /// /// ``` /// use tokio::sync::Semaphore; /// /// static SEM: Semaphore = Semaphore::const_new(10); /// ``` /// #[cfg(all(feature = "parking_lot", not(all(loom, test))))] #[cfg_a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
161
220
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
/// 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 distribute perm...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7
"poll", 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. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
241
300
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8
/// [`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.acquire(n), self.resource_span.clone(), "...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
281
340
tokio-rs/tokio:tokio/src/sync/semaphore.rs:9
/// /// 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 /// [`Se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
321
380
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11
/// join_handles.push(tokio::spawn(async move { /// // perform task... /// // explicitly own `permit` in the task /// drop(permit); /// })); /// } /// /// for handle in join_handles { /// handle.await.unwrap(); /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
401
460
tokio-rs/tokio:tokio/src/sync/semaphore.rs:12
/// acquired permit. /// /// # 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::s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
441
500
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
) -> 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", "poll", true, ); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
/// assert_eq!(semaphore.available_permits(), 0); /// /// 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
521
580
tokio-rs/tokio:tokio/src/sync/semaphore.rs:15
/// /// 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::s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
561
620
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// let permit = semaphore.acquire_many(2).await; /// assert!(permit.is_err()); /// println!("waiter received error"); /// }); /// /// println!("closing semaphore"); /// semaphore2.close(); /// /// // Cannot obtain more permits /// assert_e...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
601
660
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17
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 OwnedSemaphorePermit { /// Forgets the permit **witho...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/src/sync/semaphore.rs
641
689
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3
ll_sem: ll::Semaphore, #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: tracing::Span, } /// A permit from the semaphore. /// /// This type is created by the [`acquire`] method. /// /// [`acquire`]: crate::sync::Semaphore::acquire() #[must_use] #[derive(Debug)] pub struct SemaphorePermit<'a> { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
909de088450a31d1c472adc44532dca4910765b2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/909de088450a31d1c472adc44532dca4910765b2/tokio/src/sync/semaphore.rs
81
140
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
let semaphore = Semaphore::new(0); check_send_sync_val(semaphore.acquire()); } impl Semaphore { /// Creates a new semaphore with the initial number of permits. #[track_caller] pub fn new(permits: usize) -> Self { #[cfg(all(tokio_unstable, feature = "tracing"))] let resource_span = { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
909de088450a31d1c472adc44532dca4910765b2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/909de088450a31d1c472adc44532dca4910765b2/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5
/// ``` /// use tokio::sync::Semaphore; /// /// static SEM: Semaphore = Semaphore::const_new(10); /// ``` /// #[cfg(all(feature = "parking_lot", not(all(loom, test))))] #[cfg_attr(docsrs, doc(cfg(feature = "parking_lot")))] pub const fn const_new(permits: usize) -> Self { #[cfg(a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
909de088450a31d1c472adc44532dca4910765b2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/909de088450a31d1c472adc44532dca4910765b2/tokio/src/sync/semaphore.rs
161
220
tokio-rs/tokio:tokio/src/sync/semaphore.rs:17
} } 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 tog...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
909de088450a31d1c472adc44532dca4910765b2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/909de088450a31d1c472adc44532dca4910765b2/tokio/src/sync/semaphore.rs
641
682
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// /// // 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 semaphore is closed pub fn is_closed(&self) -> bool { self.ll_se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
53e127205bd1583a11d4ac5f650cd233550b102e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53e127205bd1583a11d4ac5f650cd233550b102e/tokio/src/sync/semaphore.rs
601
644
tokio-rs/tokio:tokio/src/sync/semaphore.rs:16
/// /// // 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 semaphore is closed pub fn is_closed(&self) -> bool { self.ll_se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
4e3268d222423e874f5bbfa67e20f773da3c025f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/sync/semaphore.rs
601
644
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3
/// A permit from the semaphore. /// /// This type is created by the [`acquire`] method. /// /// [`acquire`]: crate::sync::Semaphore::acquire() #[must_use] #[derive(Debug)] pub struct SemaphorePermit<'a> { sem: &'a Semaphore, permits: u32, } /// An owned permit from the semaphore. /// /// This type is created ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/sync/semaphore.rs
81
140
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
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), } } /// Creates a new semaphore with the initial number of permits. /// /// # Examples /// /// ``...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:11
/// [`OwnedSemaphorePermit`]: crate::sync::OwnedSemaphorePermit pub async fn acquire_many_owned( self: Arc<Self>, n: u32, ) -> Result<OwnedSemaphorePermit, AcquireError> { self.ll_sem.acquire(n).await?; Ok(OwnedSemaphorePermit { sem: self, permits: n, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/sync/semaphore.rs
401
460
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
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), } } /// Creates a new semaphore with the initial number of permits. /// /// # Examples /// /// ``...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
2ab1fb00a9f3c484d0130feb73ecef8437a915dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ab1fb00a9f3c484d0130feb73ecef8437a915dd/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
/// # Examples /// /// ``` /// use tokio::sync::Semaphore; /// /// #[tokio::main] /// async fn main() { /// let semaphore = Semaphore::new(5); /// /// let permit = semaphore.acquire_many(3).await.unwrap(); /// assert_eq!(semaphore.available_permits(), 2); /// } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
2ab1fb00a9f3c484d0130feb73ecef8437a915dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ab1fb00a9f3c484d0130feb73ecef8437a915dd/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8
/// assert_eq!(permit_2.err(), Some(TryAcquireError::NoPermits)); /// # } /// ``` /// /// [`TryAcquireError::Closed`]: crate::sync::TryAcquireError::Closed /// [`TryAcquireError::NoPermits`]: crate::sync::TryAcquireError::NoPermits /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub fn...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
2ab1fb00a9f3c484d0130feb73ecef8437a915dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ab1fb00a9f3c484d0130feb73ecef8437a915dd/tokio/src/sync/semaphore.rs
281
340
tokio-rs/tokio:tokio/src/sync/semaphore.rs:13
/// 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 { /// let permit = semaphore.acquire...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
2ab1fb00a9f3c484d0130feb73ecef8437a915dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ab1fb00a9f3c484d0130feb73ecef8437a915dd/tokio/src/sync/semaphore.rs
481
540
tokio-rs/tokio:tokio/src/sync/semaphore.rs:14
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 se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
2ab1fb00a9f3c484d0130feb73ecef8437a915dd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2ab1fb00a9f3c484d0130feb73ecef8437a915dd/tokio/src/sync/semaphore.rs
521
540
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
3a02d34d3a223244d8f880d87936059935313b66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a02d34d3a223244d8f880d87936059935313b66/tokio/src/sync/semaphore.rs
1
60
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2
pub struct SemaphorePermit<'a> { sem: &'a Semaphore, permits: u32, } /// An owned permit from the semaphore. /// /// This type is created by the [`acquire_owned`] method. /// /// [`acquire_owned`]: crate::sync::Semaphore::acquire_owned() #[must_use] #[derive(Debug)] pub struct OwnedSemaphorePermit { sem: A...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
3a02d34d3a223244d8f880d87936059935313b66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a02d34d3a223244d8f880d87936059935313b66/tokio/src/sync/semaphore.rs
41
100
tokio-rs/tokio:tokio/src/sync/semaphore.rs:3
/// Creates a new semaphore with the initial number of permits. #[cfg(all(feature = "parking_lot", not(all(loom, test))))] #[cfg_attr(docsrs, doc(cfg(feature = "parking_lot")))] pub const fn const_new(permits: usize) -> Self { Self { ll_sem: ll::Semaphore::const_new(permits), } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
3a02d34d3a223244d8f880d87936059935313b66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a02d34d3a223244d8f880d87936059935313b66/tokio/src/sync/semaphore.rs
81
140
tokio-rs/tokio:tokio/src/sync/semaphore.rs:4
/// Otherwise, this returns a [`SemaphorePermit`] representing the /// acquired permits. /// /// [`AcquireError`]: crate::sync::AcquireError /// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub async fn acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, AcquireError> { self.ll_s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
3a02d34d3a223244d8f880d87936059935313b66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a02d34d3a223244d8f880d87936059935313b66/tokio/src/sync/semaphore.rs
121
180
tokio-rs/tokio:tokio/src/sync/semaphore.rs:5
/// [`SemaphorePermit`]: crate::sync::SemaphorePermit pub fn try_acquire_many(&self, n: u32) -> Result<SemaphorePermit<'_>, TryAcquireError> { match self.ll_sem.try_acquire(n) { Ok(_) => Ok(SemaphorePermit { sem: self, permits: n, }), Err(e...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
3a02d34d3a223244d8f880d87936059935313b66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a02d34d3a223244d8f880d87936059935313b66/tokio/src/sync/semaphore.rs
161
220
tokio-rs/tokio:tokio/src/sync/semaphore.rs:6
self: Arc<Self>, n: u32, ) -> Result<OwnedSemaphorePermit, AcquireError> { self.ll_sem.acquire(n).await?; Ok(OwnedSemaphorePermit { sem: self, permits: n, }) } /// Tries to acquire a permit from the semaphore. /// /// The semaphore must be wra...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
3a02d34d3a223244d8f880d87936059935313b66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a02d34d3a223244d8f880d87936059935313b66/tokio/src/sync/semaphore.rs
201
260
tokio-rs/tokio:tokio/src/sync/semaphore.rs:7
/// [`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>, n:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
3a02d34d3a223244d8f880d87936059935313b66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a02d34d3a223244d8f880d87936059935313b66/tokio/src/sync/semaphore.rs
241
300
tokio-rs/tokio:tokio/src/sync/semaphore.rs:8
/// 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 semaphore is closed pub fn is_closed(&se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/semaphore.rs
MIT
3a02d34d3a223244d8f880d87936059935313b66
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a02d34d3a223244d8f880d87936059935313b66/tokio/src/sync/semaphore.rs
281
325
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
b05b9a1788e7b998609dae31016f2b338d6125f7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b05b9a1788e7b998609dae31016f2b338d6125f7/tokio/src/sync/semaphore.rs
1
60
tokio-rs/tokio:tokio/src/sync/semaphore.rs:2
/// This type is created by the [`acquire_owned`] method. /// /// [`acquire_owned`]: crate::sync::Semaphore::acquire_owned() #[must_use] #[derive(Debug)] pub struct OwnedSemaphorePermit { sem: Arc<Semaphore>, permits: u32, } #[test] #[cfg(not(loom))] fn bounds() { fn check_unpin<T: Unpin>() {} // This ...
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
41
100