Skip to content

Commit

Permalink
Enhance documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Mar 27, 2023
1 parent 282757c commit f1c4a0a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Sources/Semaphore/AsyncSemaphore.swift
Expand Up @@ -143,14 +143,14 @@ public final class AsyncSemaphore: @unchecked Sendable {
}
}

/// Waits for, or decrements, a semaphore.
/// Waits for, or decrements, a semaphore, with support for cancellation.
///
/// Decrement the counting semaphore. If the resulting value is less than
/// zero, this function suspends the current task until a signal occurs,
/// without blocking the underlying thread. Otherwise, no suspension happens.
///
/// - Throws: If the task is canceled before a signal occurs, this function
/// throws `CancellationError`.
/// If the task is canceled before a signal occurs, this function
/// throws `CancellationError`.
public func waitUnlessCancelled() async throws {
lock()

Expand Down Expand Up @@ -229,10 +229,12 @@ public final class AsyncSemaphore: @unchecked Sendable {
/// Signals (increments) a semaphore.
///
/// Increment the counting semaphore. If the previous value was less than
/// zero, this function resumes a task currently suspended in ``wait()``.
/// zero, this function resumes a task currently suspended in ``wait()``
/// or ``waitUnlessCancelled()``.
///
/// - returns This function returns true if a suspended task is resumed.
/// Otherwise, false is returned.
/// - returns: This function returns true if a suspended task is
/// resumed. Otherwise, the result is false, meaning that no task was
/// waiting for the semaphore.
@discardableResult
public func signal() -> Bool {
lock()
Expand Down

0 comments on commit f1c4a0a

Please sign in to comment.