I'm trying to convert some code from using NSLock
to the new Mutex
now that this bug is fixed.
In the following, I don't understand what is substantively different about these two functions that causes a compiler error in the second one:
public init(blocks: [VolBlock]) throws {
self.blocks = try Self.alloc.withLock { alloc in
try blocks.withUnsafeBufferPointer { ptr in
try alloc.alloc(blocks: ptr.baseAddress!, count: blocks.count)
}
}
}
public init(blocks: UnsafeBufferPointer<VolBlock>) throws {
self.blocks = try Self.alloc.withLock { alloc in
try alloc.alloc(blocks: blocks.baseAddress!, count: blocks.count)
// Error: 'inout sending' parameter 'alloc' cannot be task-isolated at end of function
}
}
Perhaps related to this thread but I can't make sense of it.
EDIT: ok now I get the error on the first one too when moving the withLock
inside:
public init(blocks: [VolBlock]) throws {
self.blocks = try blocks.withUnsafeBufferPointer { ptr in
try Self.alloc.withLock { alloc in
try alloc.alloc(blocks: ptr.baseAddress!, count: blocks.count)
// Error: 'inout sending' parameter 'alloc' cannot be task-isolated at end of function
}
}
}
Still don't really understand this.