You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm giving a try to Swift 6 and have to import SwiftSoup with @preconcurrency for now as it's not yet ready.
One case I have is this method:
extensionCollectionwhere Element:Sendable{func parallelMap<T:Sendable>(_ transform:@Sendable@escaping(Self.Element)throws->T)asyncrethrows->[T]{tryawaitwithThrowingTaskGroup(of:(Int, T).self){ group in
for (offset, element) in enumerated(){
group.addTask{(offset,trytransform(element))}}returntryawait group
.reduce(into:[T?](repeating:nil, count: count),{$0[$1.0]= $1.1})as![T]}}}
Which I then use to transform Elements provided by SwiftSoup:
asyncletnodes= elements.parallelMap{ element in...}
From what I understand, since Element is mutable (and thus not Sendable), the Swift compiler has no way to know that parallelMap won't mutate it from another concurrent context, while the calling context may also mutate it.
Could we have in the future some API providing sendable Elements?
Thank you!
The text was updated successfully, but these errors were encountered:
Hello,
I'm giving a try to Swift 6 and have to
import SwiftSoup
with@preconcurrency
for now as it's not yet ready.One case I have is this method:
Which I then use to transform
Elements
provided by SwiftSoup:From what I understand, since
Element
is mutable (and thus notSendable
), the Swift compiler has no way to know thatparallelMap
won't mutate it from another concurrent context, while the calling context may also mutate it.Could we have in the future some API providing sendable
Element
s?Thank you!
The text was updated successfully, but these errors were encountered: