-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
RemoteFs
methods should take immutable self
#18
Comments
I admit I've never used interior mutability before, but this will be the right time to start using it. |
Merged, but I just realized that |
Client implementation:
|
I took a quick look at the implementations in the various clients and noticed that you used a I'm not too familiar with the in-depths of multithreading, but one thing to watch out for with a I think the solution here is to use something like arc-swap. Again, I'm not too familiar with this kind of stuff, but with some basic googling and research this is what I've found. IIRC an |
Check out issue #22, might be able to solve the problem without needing any interior mutability. |
To get a gist, basically, relative paths should just be removed completely. No matter what, even if you use what I said above there could still be issues. A big one is if you change the current directory then you try and call, for example, My solution is to always use absolute paths, even in FTP where it would have to send a separate request for that. While this works, it only really works to an extent. A protocol like FTP isn't meant to be multithreaded on a single connection and typically you'd open another if you are working on a file elsewhere. So I think the goal here is to not make protocols that are not meant to be thread-safe, thread-safe. However, I do believe that relative paths should still be removed. Without relative paths, each method on FTP would first need to send a request to change the working directory, if necessary. Then, to make it actually thread-safe, the |
@veeso any thoughts on this? I might go ahead and implement it, |
Just ran across an issue where I'm trying to call methods of a struct implementing
RemoteFs
across several threads, but since theRemoteFs
trait requires thatself
must be passed mutably, I cannot access it without using some form of interior mutability, like aMutex
orRwLock
. I'm currently implementing a file system and there could be thousands of operations happening at once and using locks would mean each operation would have to wait on another resulting in a significant performance impact. Most of the protocols don't require mutability on their methods which is why this feature is reasonable, however, the ones that do could implement interior mutability themselves.The text was updated successfully, but these errors were encountered: