mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 14:15:24 +00:00
VFS Improvements (#259)
This PR refactors all of the methods on `Vfs` from accepting `&mut self` to accepting `&self` and keeping data wrapped in a mutex. This builds on previous changes to make reference count file contents and cleans up the last places where we're returning borrowed data out of the VFS interface. Once this change lands, there are two possible directions we can go that I see: * Conservative: Refactor all remaining `&mut Vfs` handles to `&Vfs` * Interesting: Embrace ref counting by changing `Vfs` methods to accept `self: Arc<Self>`, which makes the `VfsEntry` API no longer need an explicit `Vfs` argument for its operations. * Change VfsFetcher to be immutable with internal locking * Refactor Vfs::would_be_resident * Refactor Vfs::read_if_not_exists * Refactor Vfs::raise_file_removed * Refactor Vfs::raise_file_changed * Add Vfs::get_internal as bits of Vfs::get * Switch Vfs to use internal locking * Migrate all Vfs methods from &mut self to &self * Make VfsEntry access Vfs immutably * Remove outer VFS locking (#260) * Refactor all snapshot middleware to accept &Vfs instead of &mut Vfs * Remove outer VFS Mutex across the board
This commit is contained in:
committed by
GitHub
parent
5123d21290
commit
82678235ab
@@ -21,10 +21,10 @@ pub struct ChangeProcessor {
|
||||
}
|
||||
|
||||
impl ChangeProcessor {
|
||||
pub fn start<F: VfsFetcher + Send + 'static>(
|
||||
pub fn start<F: VfsFetcher + Send + Sync + 'static>(
|
||||
tree: Arc<Mutex<RojoTree>>,
|
||||
message_queue: Arc<MessageQueue<AppliedPatchSet>>,
|
||||
vfs: Arc<Mutex<Vfs<F>>>,
|
||||
vfs: Arc<Vfs<F>>,
|
||||
) -> Self {
|
||||
let (shutdown_sender, shutdown_receiver) = crossbeam_channel::bounded(1);
|
||||
|
||||
@@ -47,12 +47,9 @@ impl ChangeProcessor {
|
||||
shutdown_receiver: Receiver<()>,
|
||||
tree: Arc<Mutex<RojoTree>>,
|
||||
message_queue: Arc<MessageQueue<AppliedPatchSet>>,
|
||||
vfs: Arc<Mutex<Vfs<F>>>,
|
||||
vfs: Arc<Vfs<F>>,
|
||||
) {
|
||||
let vfs_receiver = {
|
||||
let vfs = vfs.lock().unwrap();
|
||||
vfs.change_receiver()
|
||||
};
|
||||
let vfs_receiver = vfs.change_receiver();
|
||||
|
||||
// Crossbeam's select macro generates code that Clippy doesn't like, and
|
||||
// Clippy blames us for it.
|
||||
@@ -65,7 +62,6 @@ impl ChangeProcessor {
|
||||
log::trace!("Vfs event: {:?}", event);
|
||||
|
||||
let applied_patches = {
|
||||
let mut vfs = vfs.lock().unwrap();
|
||||
vfs.commit_change(&event).expect("Error applying VFS change");
|
||||
|
||||
let mut tree = tree.lock().unwrap();
|
||||
@@ -102,7 +98,7 @@ impl ChangeProcessor {
|
||||
// TODO: Use persisted snapshot
|
||||
// context struct instead of
|
||||
// recreating it every time.
|
||||
let snapshot = snapshot_from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
||||
let snapshot = snapshot_from_vfs(&mut InstanceSnapshotContext::default(), &vfs, &entry)
|
||||
.expect("snapshot failed")
|
||||
.expect("snapshot did not return an instance");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user