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

Q: Thread-safe Connection? #23

Closed
simonklee opened this issue Mar 9, 2014 · 2 comments
Closed

Q: Thread-safe Connection? #23

simonklee opened this issue Mar 9, 2014 · 2 comments
Labels

Comments

@simonklee
Copy link

As far as I can see a Connection is not thread safe. Is that a correct assertion?

@ncw
Copy link
Owner

ncw commented Mar 9, 2014

The basic operations of the Connection are thread safe as long as your token doesn't expire.

When the token expires a re-authentication is performed. If this was performed by multiple threads it would merely be inefficient rather than incorrect I think.

I've certainly used the connection from multiple threads myself without a problem.

To be absolutely certain it could do with a bit of locking - Call should take a read lock, which it should upgrade to a write lock on re-authentication. It could also do with some tests in swift_internal_test.go which I never quite completed!

@simonklee
Copy link
Author

Yes, access to shared variables on Connection should be properly protected. Thanks for answering the question.

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

No branches or pull requests

2 participants