mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 21:41:37 +00:00
Wrap RojoTree in Mutex
This commit is contained in:
parent
7a7e9087e6
commit
1d84d3e440
2 changed files with 10 additions and 7 deletions
|
|
@ -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},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue