mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-24 06:34:09 +00:00
Tinker with concurrency with FsSession
This commit is contained in:
parent
817ee31a23
commit
591b9c5f9a
2 changed files with 23 additions and 10 deletions
|
|
@ -1,8 +1,9 @@
|
|||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::time::Instant;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
use std::time::Instant;
|
||||
|
||||
use rand;
|
||||
|
||||
|
|
@ -55,10 +56,22 @@ pub fn serve(project_path: &PathBuf, port: Option<u64>) {
|
|||
|
||||
println!("Using session config {:#?}", config);
|
||||
|
||||
let mut session = FsSession::new(&config);
|
||||
session.init();
|
||||
let session = {
|
||||
let mut session = FsSession::new(config.clone());
|
||||
session.init();
|
||||
|
||||
Arc::new(Mutex::new(session))
|
||||
};
|
||||
|
||||
// TODO: Let FsSession handle the main loop and spawn a bunch of threads
|
||||
// ...since Rust stable doesn't have a channel select implementation
|
||||
thread::spawn(move || {
|
||||
loop {
|
||||
session.lock().unwrap().step();
|
||||
}
|
||||
});
|
||||
|
||||
loop {
|
||||
session.step();
|
||||
thread::park();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue