@@ -318,7 +318,9 @@ public struct ExecutorJob: Sendable, ~Copyable {
318
318
}
319
319
320
320
/// 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.
322
324
///
323
325
/// Parameters:
324
326
///
@@ -510,9 +512,8 @@ extension ExecutorJob {
510
512
/// A job-local stack-disciplined allocator.
511
513
///
512
514
/// 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.
516
517
///
517
518
/// N.B. Because this allocator is stack disciplined, explicitly
518
519
/// deallocating memory out-of-order will cause your program to abort.
@@ -540,23 +541,20 @@ extension ExecutorJob {
540
541
return unsafe UnsafeMutableBufferPointer< T > ( start: typedBase, count: capacity)
541
542
}
542
543
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.
546
546
public func deallocate( _ buffer: UnsafeMutableRawBufferPointer ) {
547
547
unsafe _jobDeallocate( context, buffer. baseAddress!)
548
548
}
549
549
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.
553
552
public func deallocate< T> ( _ pointer: UnsafeMutablePointer < T > ) {
554
553
unsafe _jobDeallocate( context, UnsafeMutableRawPointer ( pointer) )
555
554
}
556
555
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.
560
558
public func deallocate< T> ( _ buffer: UnsafeMutableBufferPointer < T > ) {
561
559
unsafe _jobDeallocate( context, UnsafeMutableRawPointer ( buffer. baseAddress!) )
562
560
}
0 commit comments