Skip to content

Commit 250458f

Browse files
committed
[Concurrency] Add a couple of comments.
Add some documentation comments to the Dispatch and CF executors, and update the comments for the allocation and private data APIs.
1 parent 0fbd382 commit 250458f

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

stdlib/public/Concurrency/CFExecutor.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum CoreFoundation {
4747

4848
// .. Main Executor ............................................................
4949

50+
/// A CFRunLoop-based main executor (Apple platforms only)
5051
@available(StdlibDeploymentTarget 6.2, *)
5152
public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {
5253

@@ -62,6 +63,7 @@ public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {
6263

6364
// .. Task Executor ............................................................
6465

66+
/// A `TaskExecutor` to match `CFMainExecutor` (Apple platforms only)
6567
@available(StdlibDeploymentTarget 6.2, *)
6668
public final class CFTaskExecutor: DispatchGlobalTaskExecutor,
6769
@unchecked Sendable {

stdlib/public/Concurrency/DispatchExecutor.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Swift
2323

2424
// .. Main Executor ............................................................
2525

26+
/// A Dispatch-based main executor.
2627
@available(StdlibDeploymentTarget 6.2, *)
2728
public class DispatchMainExecutor: RunLoopExecutor, SchedulingExecutor,
2829
@unchecked Sendable {
@@ -75,6 +76,7 @@ extension DispatchMainExecutor: MainExecutor {}
7576

7677
// .. Task Executor ............................................................
7778

79+
/// A Dispatch-based `TaskExecutor`
7880
@available(StdlibDeploymentTarget 6.2, *)
7981
public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulingExecutor,
8082
@unchecked Sendable {

stdlib/public/Concurrency/PartialAsyncTask.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ public struct ExecutorJob: Sendable, ~Copyable {
318318
}
319319

320320
/// Execute a closure, passing it the bounds of the executor private data
321-
/// for the job.
321+
/// for the job. The executor is responsible for ensuring that any resources
322+
/// referenced from the private data area are cleared up prior to running the
323+
/// job.
322324
///
323325
/// Parameters:
324326
///
@@ -510,9 +512,8 @@ extension ExecutorJob {
510512
/// A job-local stack-disciplined allocator.
511513
///
512514
/// This can be used to allocate additional data required by an
513-
/// executor implementation; memory allocated in this manner will
514-
/// be released automatically when the job is disposed of by the
515-
/// runtime.
515+
/// executor implementation; memory allocated in this manner must
516+
/// be released by the executor before the job is executed.
516517
///
517518
/// N.B. Because this allocator is stack disciplined, explicitly
518519
/// deallocating memory out-of-order will cause your program to abort.
@@ -540,23 +541,20 @@ extension ExecutorJob {
540541
return unsafe UnsafeMutableBufferPointer<T>(start: typedBase, count: capacity)
541542
}
542543

543-
/// Deallocate previously allocated memory. Note that the task
544-
/// allocator is stack disciplined, so if you deallocate a block of
545-
/// memory, all memory allocated after that block is also deallocated.
544+
/// Deallocate previously allocated memory. You must do this in
545+
/// reverse order of allocations, prior to running the job.
546546
public func deallocate(_ buffer: UnsafeMutableRawBufferPointer) {
547547
unsafe _jobDeallocate(context, buffer.baseAddress!)
548548
}
549549

550-
/// Deallocate previously allocated memory. Note that the task
551-
/// allocator is stack disciplined, so if you deallocate a block of
552-
/// memory, all memory allocated after that block is also deallocated.
550+
/// Deallocate previously allocated memory. You must do this in
551+
/// reverse order of allocations, prior to running the job.
553552
public func deallocate<T>(_ pointer: UnsafeMutablePointer<T>) {
554553
unsafe _jobDeallocate(context, UnsafeMutableRawPointer(pointer))
555554
}
556555

557-
/// Deallocate previously allocated memory. Note that the task
558-
/// allocator is stack disciplined, so if you deallocate a block of
559-
/// memory, all memory allocated after that block is also deallocated.
556+
/// Deallocate previously allocated memory. You must do this in
557+
/// reverse order of allocations, prior to running the job.
560558
public func deallocate<T>(_ buffer: UnsafeMutableBufferPointer<T>) {
561559
unsafe _jobDeallocate(context, UnsafeMutableRawPointer(buffer.baseAddress!))
562560
}

0 commit comments

Comments
 (0)