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

[0pt] Add cancellation support to ThreadPool #244

Closed
ivan-cukic opened this issue Dec 6, 2022 · 1 comment · Fixed by fair-acc/gnuradio4#67 or fair-acc/gnuradio4#78
Closed

[0pt] Add cancellation support to ThreadPool #244

ivan-cukic opened this issue Dec 6, 2022 · 1 comment · Fixed by fair-acc/gnuradio4#67 or fair-acc/gnuradio4#78

Comments

@ivan-cukic
Copy link
Collaborator

ivan-cukic commented Dec 6, 2022

Make the following use-case work:

TEST_CASE("ThreadPool: Cancellation", "[ThreadPool][Cancellation]") {
    std::atomic<int>                            counter{ 0 };
    opencmw::BasicThreadPool<opencmw::IO_BOUND> pool("contention", 1, 4);
    pool.waitUntilInitialised();
    pool.execute(
            [&counter](std::stop_token stop_token) {
                while (!stop_token.stop_requested()) {
                    std::this_thread::sleep_for(std::chrono::milliseconds(10));
                }
            });
}

This will allow interrupting running threads when the application wants to shut down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants