Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

PeterAdams-A
Copy link
Contributor

Motivation:

The old lock used is deprecated.

Modifications:

Move to using NIOLockedValueBox

Result:

No deprecation warnings

Motivation:

The old lock used is deprecated.

Modifications:

Move to using NIOLockedValueBox

Result:

No deprecation warnings
}
switch state {
case .connected:
try self.disconect()
Copy link

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)
Copy link

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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants