Skip to content

Conversation

@banditopazzo
Copy link
Contributor

This PR wants to make changes to improve the main loop.

Currently the main loop is using a VecDeque to schedule jobs on the threadpool, but the threadpool implements an internal queue itself, so basically there the code is redundant.

You can test this Threadpool behaviour with these simple lines:

fn main() {
    let pool = threadpool::ThreadPool::new(3);

    for x in 0..6 {
        pool.execute(move || {
            println!("start work {x}");

            std::thread::sleep(std::time::Duration::from_secs(3));

            println!("end work {x}");
        });
    }

    pool.join();
}

There is also a manual thread::sleep that can be avoided, relying on the Receiver::recv function and without actively checking for results in the channel receiver.

I think in general the main loop will be less convoluted.

@devttys0 devttys0 merged commit e96a577 into ReFirmLabs:binwalkv3 Oct 8, 2024
@devttys0
Copy link
Collaborator

devttys0 commented Oct 8, 2024

This is indeed much cleaner. :) Much obliged!

@banditopazzo banditopazzo deleted the main_loop_refactor branch October 19, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants