Skip to content

Commit 4f38bfe

Browse files
committed
Improve comments in SemaphoreTests
1 parent bc349b2 commit 4f38bfe

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Tests/AsyncQueueTests/SemaphoreTests.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,15 @@ final class SemaphoreTests: XCTestCase {
115115
// MARK: - Semaphore Extension
116116

117117
private extension Semaphore {
118-
/// Enqueues an asynchronous task. This method suspends the caller until the asynchronous task has begun, ensuring ordered execution of enqueued tasks.
118+
/// Enqueues an asynchronous task and increments a counter after the task completes.
119+
/// This method suspends the caller until the asynchronous task has begun, ensuring ordered execution of enqueued tasks.
119120
/// - Parameter task: A unit of work that returns work to execute after the task completes and the count is incremented.
120121
func enqueueAndCount(using counter: UnsafeCounter, _ task: @escaping @Sendable (isolated Semaphore) async -> ((isolated Semaphore) -> Void)?) async {
121122
// Await the start of the soon-to-be-enqueued `Task` with a continuation.
122123
await withCheckedContinuation { continuation in
123-
// Re-enter the actor context but don't wait for the result.
124+
// Re-enter the semaphore's ordered context but don't wait for the result.
124125
Task {
125-
// Now that we're back in the actor context, resume the calling code.
126+
// Now that we're back in the semaphore's ordered context, allow the calling code to resume.
126127
continuation.resume()
127128
let executeAfterIncrement = await task(self)
128129
counter.countedTasksCompleted += 1

0 commit comments

Comments
 (0)