Skip to content

Commit

Permalink
sync: document maximum number of permits (#2539)
Browse files Browse the repository at this point in the history
  • Loading branch information
NOVA-ME authored May 16, 2020
1 parent a343b1d commit a5c1a7d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion tokio/src/sync/batch_semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tokio/src/sync/semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion tokio/src/sync/semaphore_ll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a5c1a7d

Please sign in to comment.