Skip to content

Commit

Permalink
clippy2
Browse files Browse the repository at this point in the history
  • Loading branch information
hinto-janai committed May 13, 2023
1 parent a30fb03 commit ec48398
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
12 changes: 8 additions & 4 deletions gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,23 @@ fn main() {
let (gui_to_kernel, kernel_recv) = crossbeam_channel::unbounded::<shukusai::kernel::FrontendToKernel>();

// Start `egui/eframe`.
eframe::run_native(
if let Err(e) = eframe::run_native(
shukusai::FESTIVAL_NAME_VER,
data::Gui::options(),
Box::new(|cc| {
// Spawn `Kernel`, pass it `egui::Context`.
shukusai::kernel::Kernel::spawn(
if let Err(e) = shukusai::kernel::Kernel::spawn(
kernel_to_gui,
kernel_recv,
cc.egui_ctx.clone()
).expect("Kernel::spawn() failed");
) {
panic!("Kernel::spawn() failed: {e}");
}

// Start `GUI`.
Box::new(data::Gui::init(cc, gui_to_kernel, gui_recv))
})
).expect("eframe::run_native() failed");
) {
panic!("eframe::run_native() failed: {e}");
}
}
35 changes: 25 additions & 10 deletions src/kernel/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,12 @@ impl Kernel {
debug!("Kernel [3/12] ... spawning CCD");
let (ccd_send, from_ccd) = crossbeam_channel::unbounded::<CcdToKernel>();
let ctx_clone = ctx.clone();
std::thread::Builder::new()
if let Err(e) = std::thread::Builder::new()
.name("CCD".to_string())
.spawn(move || Ccd::convert_art(ccd_send, collection, ctx_clone));
.spawn(move || Ccd::convert_art(ccd_send, collection, ctx_clone))
{
panic!("Kernel - failed to spawn CCD: {e}");
}

// Before hanging on `CCD`, read `KernelState` file.
// Note: This is a `Result`.
Expand Down Expand Up @@ -319,23 +322,32 @@ impl Kernel {
// Spawn `Search`.
debug!("Kernel [10/12] ... spawning Search");
let collection = Arc::clone(&kernel.collection);
std::thread::Builder::new()
if let Err(e) = std::thread::Builder::new()
.name("Search".to_string())
.spawn(move || Search::init(collection, search_send, search_recv));
.spawn(move || Search::init(collection, search_send, search_recv))
{
panic!("Kernel - failed to spawn Search: {e}");
}

// Spawn `Audio`.
debug!("Kernel [11/12] ... spawning Audio");
let collection = Arc::clone(&kernel.collection);
let state = RoLock::new(&kernel.state);
std::thread::Builder::new()
if let Err(e) = std::thread::Builder::new()
.name("Audio".to_string())
.spawn(move || Audio::init(collection, state, audio_send, audio_recv));
.spawn(move || Audio::init(collection, state, audio_send, audio_recv))
{
panic!("Kernel - failed to spawn Audio: {e}");
}

// Spawn `Watch`.
debug!("Kernel [12/12] ... spawning Watch");
std::thread::Builder::new()
if let Err(e) = std::thread::Builder::new()
.name("Watch".to_string())
.spawn(move || Watch::init(watch_send));
.spawn(move || Watch::init(watch_send))
{
panic!("Kernel - failed to spawn Audio: {e}");
}

// We're done, enter main `userspace` loop.
ok_debug!("Kernel - Entering 'userspace()' ... Took {} seconds total", secs_f32!(beginning));
Expand Down Expand Up @@ -516,10 +528,13 @@ impl Kernel {
lockw!(self.reset).start();

// Spawn `CCD`.
std::thread::Builder::new()
if let Err(e) = std::thread::Builder::new()
.name("CCD".to_string())
.stack_size(16_000_000) // 16MB stack.
.spawn(move || Ccd::new_collection(ccd_send, ccd_recv, kernel_state, old_collection, paths, ctx));
.spawn(move || Ccd::new_collection(ccd_send, ccd_recv, kernel_state, old_collection, paths, ctx))
{
panic!("Kernel - failed to spawn CCD: {e}");
}

// Listen to `CCD`.
self.collection = loop {
Expand Down
10 changes: 5 additions & 5 deletions src/watch/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ impl Watch {
fn main(self) {
ok_debug!("Watch");

use notify::event::{EventKind,CreateKind};

loop {
// Wait for a change in the filesystem.
// We only care if it was a file creation.
loop {
if let Ok(Ok(event)) = self.from_notify.recv() { // If we got a msg...
if let notify::event::EventKind::Create(kind) = event.kind { // and it was a `Create`...
if let notify::event::CreateKind::File = kind { // and it was a `File`...
break // break, and check files.
}
if let Ok(Ok(event)) = self.from_notify.recv() { // If we got a msg...
if let EventKind::Create(CreateKind::File) = event.kind { // and it was a `Create` and it was a `File`...
break // break, and check files.
}
}
}
Expand Down

0 comments on commit ec48398

Please sign in to comment.