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

Multi-threaded endgame tables #26

Open
oggy22 opened this issue Oct 23, 2024 · 1 comment
Open

Multi-threaded endgame tables #26

oggy22 opened this issue Oct 23, 2024 · 1 comment

Comments

@oggy22
Copy link
Owner

oggy22 commented Oct 23, 2024

Make use of multithreading, possibly std::future and related classes.

The Dependent tables should be created each in separate tasks. All tasks should be waited for to create the current table.

This depends on #24

@oggy22
Copy link
Owner Author

oggy22 commented Oct 23, 2024

A very nice starting example using std::future and std::async:

#include <iostream>
#include <future>

// Function to calculate Fibonacci number
int fibonacci(int n) {
    if (n <= 1) return n;
    return fibonacci(n - 1) + fibonacci(n - 2);
}

int main() {
    // Launch asynchronous task
    std::future<int> result = std::async(std::launch::async, fibonacci, 46);

    // Do some other work while waiting for the result
    std::cout << "Calculating Fibonacci(10) asynchronously..." << std::endl;

    // Get the result from the future
    int fib10 = result.get();

    std::cout << "Fibonacci(10) = " << fib10 << std::endl;

    return 0;
}

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

No branches or pull requests

1 participant