[SENDING REGRET] Pool async methods require Sendable closures

We should be able to use sending closures instead, but DispatchQueue.async does not accept sending closures yet.
This commit is contained in:
Gwendal Roué committed 2024-09-08 16:09:19 +02:00
1 parent 0b6ac870e2
commit 55560ccd90
1 file changed
+2 -2
+2 -2
View File
@@ -121,7 +121,7 @@ final class Pool<T: Sendable>: Sendable {
///
/// - important: The `execute` argument is executed in a serial dispatch
/// queue, so make sure you use the element asynchronously.
func asyncGet(_ execute: @escaping (Result<ElementAndRelease, Error>) -> Void) {
func asyncGet(_ execute: @escaping @Sendable (Result<ElementAndRelease, Error>) -> Void) {
// Inspired by https://khanlou.com/2016/04/the-GCD-handbook/
// > We wait on the semaphore in the serial queue, which means that
// > we’ll have at most one blocked thread when we reach maximum
@@ -186,7 +186,7 @@ final class Pool<T: Sendable>: Sendable {
/// Asynchronously runs the `barrier` function when no element is used, and
/// before any other element is dequeued.
func asyncBarrier(execute barrier: @escaping () -> Void) {
func asyncBarrier(execute barrier: @escaping @Sendable () -> Void) {
barrierQueue.async(flags: [.barrier]) {
self.itemsGroup.wait()
barrier()