-
Notifications
You must be signed in to change notification settings - Fork 23
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
Use LockedValueBoxes for state protection #35
base: main
Are you sure you want to change the base?
Conversation
Motivation: The old lock used is deprecated. Modifications: Move to using NIOLockedValueBox Result: No deprecation warnings
} | ||
switch state { | ||
case .connected: | ||
try self.disconect() |
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.
I'm pretty nervous about this function being called with the lock held.
switch self.state { | ||
let (startingState, future) = self.stateStore.withLockedValue { (state: inout State) -> (State, EventLoopFuture<Void>?) in | ||
if case .idle = state { | ||
let future = self.connect(on: eventLoop, logger: logger) |
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.
Same notes here.
lock.unlock() | ||
let (startingState, task) = self.stateStore.withLockedValue { (state: inout State) -> (State, Task<Void, Swift.Error>?) in | ||
if case .idle = state { | ||
let task = self.connect(logger: logger) |
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.
And here.
Motivation:
The old lock used is deprecated.
Modifications:
Move to using NIOLockedValueBox
Result:
No deprecation warnings