sync: document maximum number of permits (#2539)

This commit is contained in:
ZSL
2020-05-16 12:41:45 +02:00
committed by GitHub
parent a343b1d180
commit a5c1a7de03
4 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -228,7 +228,7 @@
//! on the number of blocking threads is very large. These limits can be
//! configured on the [`Builder`].
//!
//! Two spawn a blocking task, you should use the [`spawn_blocking`] function.
//! To spawn a blocking task, you should use the [`spawn_blocking`] function.
//!
//! [`Builder`]: crate::runtime::Builder
//! [`spawn_blocking`]: crate::task::spawn_blocking()
+3 -1
View File
@@ -123,7 +123,9 @@ impl Semaphore {
self.permits.load(Acquire) >> Self::PERMIT_SHIFT
}
/// Adds `n` new permits to the semaphore.
/// Adds `added` new permits to the semaphore.
///
/// The maximum number of permits is `usize::MAX >> 3`, and this function will panic if the limit is exceeded.
pub(crate) fn release(&self, added: usize) {
if added == 0 {
return;
+2
View File
@@ -80,6 +80,8 @@ impl Semaphore {
}
/// Adds `n` new permits to the semaphore.
///
/// The maximum number of permits is `usize::MAX >> 3`, and this function will panic if the limit is exceeded.
pub fn add_permits(&self, n: usize) {
self.ll_sem.release(n);
}
+2 -1
View File
@@ -333,8 +333,9 @@ impl Semaphore {
self.add_permits_locked(0, true);
}
/// Adds `n` new permits to the semaphore.
///
/// The maximum number of permits is `usize::MAX >> 3`, and this function will panic if the limit is exceeded.
pub(crate) fn add_permits(&self, n: usize) {
if n == 0 {
return;