mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-26 07:36:19 +00:00
Wrap RojoTree in Mutex
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
use std::collections::HashSet;
|
use std::{
|
||||||
|
collections::HashSet,
|
||||||
|
sync::{Mutex, MutexGuard},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::new::{Imfs, ImfsFetcher},
|
imfs::new::{Imfs, ImfsFetcher},
|
||||||
@@ -12,7 +15,7 @@ use crate::{
|
|||||||
pub struct ServeSession<F> {
|
pub struct ServeSession<F> {
|
||||||
root_project: Option<Project>,
|
root_project: Option<Project>,
|
||||||
session_id: SessionId,
|
session_id: SessionId,
|
||||||
tree: RojoTree,
|
tree: Mutex<RojoTree>,
|
||||||
message_queue: MessageQueue<()>, // TODO: Real message type
|
message_queue: MessageQueue<()>, // TODO: Real message type
|
||||||
imfs: Imfs<F>,
|
imfs: Imfs<F>,
|
||||||
}
|
}
|
||||||
@@ -25,14 +28,14 @@ impl<F: ImfsFetcher> ServeSession<F> {
|
|||||||
ServeSession {
|
ServeSession {
|
||||||
session_id,
|
session_id,
|
||||||
root_project,
|
root_project,
|
||||||
tree,
|
tree: Mutex::new(tree),
|
||||||
message_queue,
|
message_queue,
|
||||||
imfs,
|
imfs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tree(&self) -> &RojoTree {
|
pub fn tree(&self) -> MutexGuard<'_, RojoTree> {
|
||||||
&self.tree
|
self.tree.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn imfs(&self) -> &Imfs<F> {
|
pub fn imfs(&self) -> &Imfs<F> {
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ use crate::{
|
|||||||
serve_session::ServeSession,
|
serve_session::ServeSession,
|
||||||
web::{
|
web::{
|
||||||
interface::{
|
interface::{
|
||||||
Instance, NotFoundError, ReadResponse, ServerInfoResponse, SubscribeResponse,
|
Instance, NotFoundError, ReadResponse, ServerInfoResponse, PROTOCOL_VERSION,
|
||||||
PROTOCOL_VERSION, SERVER_VERSION,
|
SERVER_VERSION,
|
||||||
},
|
},
|
||||||
util::{json, json_ok},
|
util::{json, json_ok},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user