Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main loop refactor: remove redundant queue and no active waiting for results #690

Merged
merged 3 commits into from
Oct 8, 2024

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
1 check passed
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants