mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
give more threads a fixed name
This commit is contained in:
parent
c51a2b10a0
commit
fdc40f52d9
@ -56,13 +56,29 @@ impl Tui {
|
||||
}
|
||||
|
||||
pub fn run(basic: bool) -> Self {
|
||||
let (mut msg_s, msg_r) = mpsc::channel();
|
||||
let (msg_s, msg_r) = mpsc::channel();
|
||||
let running = Arc::new(AtomicBool::new(true));
|
||||
let running2 = Arc::clone(&running);
|
||||
|
||||
let builder = std::thread::Builder::new().name("tui_runner".to_owned());
|
||||
let background = if basic {
|
||||
std::thread::spawn(move || {
|
||||
while running2.load(Ordering::Relaxed) {
|
||||
builder.spawn(|| Self::work_b(running2, msg_s)).unwrap();
|
||||
None
|
||||
} else {
|
||||
Some(builder.spawn(|| Self::work_e(running2, msg_s)).unwrap())
|
||||
};
|
||||
|
||||
Self {
|
||||
msg_r,
|
||||
background,
|
||||
basic,
|
||||
running,
|
||||
}
|
||||
}
|
||||
|
||||
/// In a seperate Thread
|
||||
fn work_b(running: Arc<AtomicBool>, mut msg_s: mpsc::Sender<Message>) {
|
||||
while running.load(Ordering::Relaxed) {
|
||||
let mut line = String::new();
|
||||
|
||||
match io::stdin().read_line(&mut line) {
|
||||
@ -84,11 +100,10 @@ impl Tui {
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
None
|
||||
} else {
|
||||
Some(std::thread::spawn(move || {
|
||||
/// In a seperate Thread
|
||||
fn work_e(running: Arc<AtomicBool>, mut msg_s: mpsc::Sender<Message>) {
|
||||
// Start the tui
|
||||
let mut stdout = io::stdout();
|
||||
execute!(stdout, EnterAlternateScreen, EnableMouseCapture).unwrap();
|
||||
@ -104,7 +119,7 @@ impl Tui {
|
||||
error!(?e, "couldn't clean terminal");
|
||||
};
|
||||
|
||||
while running2.load(Ordering::Relaxed) {
|
||||
while running.load(Ordering::Relaxed) {
|
||||
if let Err(e) = terminal.draw(|f| {
|
||||
let (log_rect, input_rect) = if f.size().height > 6 {
|
||||
let mut log_rect = f.size();
|
||||
@ -153,15 +168,6 @@ impl Tui {
|
||||
Self::handle_events(&mut input, &mut msg_s);
|
||||
};
|
||||
}
|
||||
}))
|
||||
};
|
||||
|
||||
Self {
|
||||
msg_r,
|
||||
background,
|
||||
basic,
|
||||
running,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn shutdown(basic: bool) {
|
||||
|
@ -146,7 +146,7 @@ pub fn init() {
|
||||
// Start reloader that watcher signals
|
||||
// "Debounces" events since I can't find the option to do this in the latest
|
||||
// `notify`
|
||||
thread::spawn(move || {
|
||||
std::thread::Builder::new("voxygen_anim_watcher".to_owned()).spawn(move || {
|
||||
let mut modified_paths = std::collections::HashSet::new();
|
||||
while let Ok(path) = reload_recv.recv() {
|
||||
modified_paths.insert(path);
|
||||
|
Loading…
Reference in New Issue
Block a user