Closed wmanley closed 2 years ago
Thanks, this looks cool! I've wanted to have multi-threaded support for a while. I haven't read through it all yet, but a couple early bits of feedback:
1) I don't really like the idea of a factory function for Filesystem
when using multi-threading. There are a number of cases where you want to have Filesystem be a singleton, such as caching & cache invalidation. The way I'd been thinking of implementing multi-threading was to use async
by adding a new Filesystem2
trait that was async
2) what's the use case for splitting serve_fs_sync_forever
out of mount3
?
Closing due to inactivity, but feel free to re-open, if you work on this more
The new
mount3
andserve_fs_sync_forever
APIs allow for more control over the lifecycle of your filesystem. Mounting the filesystem is now separate from the request handling loop. We also apply the typestate pattern to handle filesystem init, rather than having that as part of the request handling loop.This provides additional flexibility. We no longer need to implement
BackgroundSession
, users can just as easily callthread::spawn
themselves.Example equivalent to
mount2
:Example equivalent to
Session...::spawn()
:rather than having specific APIs to enable background thread operation.
I've also added
serve_fs_mt_forever
enabling multi-threaded filesystems using rayon. I'm quite pleased with how its worked out as I've been able to add this without having a separateFilesystem
trait taking&self
instead of&mut self
.Raising as a PR now for early visibility.
TODO: