diff options
Diffstat (limited to 'tokio/src/sync/semaphore.rs')
-rw-r--r-- | tokio/src/sync/semaphore.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tokio/src/sync/semaphore.rs b/tokio/src/sync/semaphore.rs index 2489d34a..136f14e6 100644 --- a/tokio/src/sync/semaphore.rs +++ b/tokio/src/sync/semaphore.rs @@ -74,6 +74,15 @@ impl Semaphore { } } + /// 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), + } + } + /// Returns the current number of available permits. pub fn available_permits(&self) -> usize { self.ll_sem.available_permits() |