@@ -309,7 +309,9 @@ public struct ExecutorJob: Sendable, ~Copyable {
309
309
}
310
310
311
311
/// Execute a closure, passing it the bounds of the executor private data
312
- /// for the job.
312
+ /// for the job. The executor is responsible for ensuring that any resources
313
+ /// referenced from the private data area are cleared up prior to running the
314
+ /// job.
313
315
///
314
316
/// Parameters:
315
317
///
@@ -501,9 +503,8 @@ extension ExecutorJob {
501
503
/// A job-local stack-disciplined allocator.
502
504
///
503
505
/// This can be used to allocate additional data required by an
504
- /// executor implementation; memory allocated in this manner will
505
- /// be released automatically when the job is disposed of by the
506
- /// runtime.
506
+ /// executor implementation; memory allocated in this manner must
507
+ /// be released by the executor before the job is executed.
507
508
///
508
509
/// N.B. Because this allocator is stack disciplined, explicitly
509
510
/// deallocating memory out-of-order will cause your program to abort.
@@ -531,23 +532,20 @@ extension ExecutorJob {
531
532
return unsafe UnsafeMutableBufferPointer< T > ( start: typedBase, count: capacity)
532
533
}
533
534
534
- /// Deallocate previously allocated memory. Note that the task
535
- /// allocator is stack disciplined, so if you deallocate a block of
536
- /// memory, all memory allocated after that block is also deallocated.
535
+ /// Deallocate previously allocated memory. You must do this in
536
+ /// reverse order of allocations, prior to running the job.
537
537
public func deallocate( _ buffer: UnsafeMutableRawBufferPointer ) {
538
538
unsafe _jobDeallocate( context, buffer. baseAddress!)
539
539
}
540
540
541
- /// Deallocate previously allocated memory. Note that the task
542
- /// allocator is stack disciplined, so if you deallocate a block of
543
- /// memory, all memory allocated after that block is also deallocated.
541
+ /// Deallocate previously allocated memory. You must do this in
542
+ /// reverse order of allocations, prior to running the job.
544
543
public func deallocate< T> ( _ pointer: UnsafeMutablePointer < T > ) {
545
544
unsafe _jobDeallocate( context, UnsafeMutableRawPointer ( pointer) )
546
545
}
547
546
548
- /// Deallocate previously allocated memory. Note that the task
549
- /// allocator is stack disciplined, so if you deallocate a block of
550
- /// memory, all memory allocated after that block is also deallocated.
547
+ /// Deallocate previously allocated memory. You must do this in
548
+ /// reverse order of allocations, prior to running the job.
551
549
public func deallocate< T> ( _ buffer: UnsafeMutableBufferPointer < T > ) {
552
550
unsafe _jobDeallocate( context, UnsafeMutableRawPointer ( buffer. baseAddress!) )
553
551
}
0 commit comments