-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Excessive locking #626
Comments
I came across this on some ocassions I believe, it's possible to deadlock in some cases if you try to run some of the API synchronously (I believe it was MoveFileAsync). I don't have anything reproductible though and as long as everything is done asynchronously it doesn't seem to be a problem. |
But it's not exactly related to synchonously/asynchronously but rather with regards to concurrent asynchronous tasks. |
The current implementation should allow concurrent usage of multiple filestreams for a single file, and concurrent usage of filestreams from different files. The intent of the implementation is:
[0] if there are multiple files in the torrent, then they'll all lock on a different There is also an implicit assumption that access to the
DiskWriter methods being 'correct'.
Which part of this were you suggestingchanging the synchronization model for? That said, i'll still check out the code you suggested! I'm curious to see how others approach these sorts of problems! |
I looked at your locking mechanism out of interest because I wrote a locking library myself. I noticed that you may be locking quite excessively and I'm not sure if it's done purposely. For example, if you want to lock on a specific file or on AllStreams, you would not be allowing concurrency for different files/streams. If you don't want this behaviour, you need to consider using a keyed locking library instead, such as the one I made at https://github.com/MarkCiliaVincenti/AsyncKeyedLock which also allows pooling helping to reduce allocations.
The text was updated successfully, but these errors were encountered: