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
Thread.current is very useful as a debugging mechanism to understand the ordering of code running concurrently and/or in parallel. This is very useful to use from async functions.
Sure, the workaround is just
extension Thread {
public static var currentThread: Thread {
return Thread.current
}
}
but that shouldn't be necessary.
The text was updated successfully, but these errors were encountered:
Maybe it's useful for debugging, but it's wrong to conflate a task with a thread. Making this API available in async contexts seems like a mistake to me. @phausler did the original audit, though, so pulling him in for his opinion.
Maybe it's useful for debugging, but it's wrong to conflate a task with a thread. Making this API available in async contexts seems like a mistake to me. @phausler did the original audit, though, so pulling him in for his opinion.
Sure, it's important to not conflate tasks & threads, just like it was always important to not conflate DispatchQueues and threads. And yet we didn't try to ban you calling Thread.current from a DispatchQueue. And it's really important for debugging (and sometimes even when logging around problematic sections).
Also: Allowing it anywhere doesn't cause any hard, we're using it anyway but today we have to work around it (with that extension Thread)
swift-corelibs-foundation/Sources/Foundation/Thread.swift
Line 85 in c28bf23
Thread.current
is very useful as a debugging mechanism to understand the ordering of code running concurrently and/or in parallel. This is very useful to use fromasync
functions.Sure, the workaround is just
but that shouldn't be necessary.
The text was updated successfully, but these errors were encountered: