B2.NET icon indicating copy to clipboard operation
B2.NET copied to clipboard

Is B2Client thread-safe?

Open danports opened this issue 4 years ago • 2 comments

I'm guessing it is not because of things like this:

https://github.com/coryrwest/B2.NET/blob/07d3f749c16655bbfb7c6a5dd40cd534d3b97576/src/Files.cs#L124

It would be nice if it were since the underlying HttpClient is, but if that requires too much effort, perhaps a line in the documentation clarifying the library's thread safety would be helpful.

danports avatar Apr 22 '20 04:04 danports

I am admittedly not as well experienced/read in thread-safety as I could be. I am not sure of the changes require and their extensiveness to be completely thread-safe. I will have to do some research.

coryrwest avatar Apr 22 '20 14:04 coryrwest

From my brief review of the library's internals, I didn't notice many thread safety issues - the only glaring one I noticed is the way that the B2Options class is used to pass state around in several places, and that can probably be easily avoided by passing context on the stack instead (e.g. passing the upload authorization token directly to FileUploadRequestGenerators.Upload as an argument).

Of course, the simplest approach to start would just to be document that the library is not thread-safe. 😂

danports avatar Apr 24 '20 20:04 danports