-
Notifications
You must be signed in to change notification settings - Fork 125
Fix a few simple sendability issues #832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Motivation: We're about to go on a sendability journey. Let's pick some low hanging fruit to get started. Modifications: - Add a few assume-isolated calls - Stop using static var - Use a dispatch group instead of a work item to wait for work to be done. Result: Fewer warnings
@@ -223,17 +223,18 @@ public class HTTPClient { | |||
) | |||
} | |||
let errorStorage: NIOLockedValueBox<Error?> = NIOLockedValueBox(nil) | |||
let continuation = DispatchWorkItem {} | |||
let dispatchGroup = DispatchGroup() | |||
dispatchGroup.enter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this should probably use the condition variable workaround we used in NIO to avoid triggering the main thread checker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, good idea
@@ -26,7 +26,9 @@ extension HTTPConnectionPool { | |||
self.connection = connection | |||
} | |||
|
|||
static let none = Action(request: .none, connection: .none) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially silly question but was this unsafe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not "unsafe" per-se as neither .none
case contains anything. However, Action
isn't Sendable
(and shouldn't be) so the compiler appropriately produces a warning here.
Motivation:
We're about to go on a sendability journey. Let's pick some low hanging fruit to get started.
Modifications:
Result:
Fewer warnings