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

Adding multi-threading? #65

Open
Wouze opened this issue Feb 22, 2023 · 0 comments
Open

Adding multi-threading? #65

Wouze opened this issue Feb 22, 2023 · 0 comments

Comments

@Wouze
Copy link

Wouze commented Feb 22, 2023

Hey I'm kinda new to c++ stuff and I've been trying to use multi-threading, because I just have watched a video about it :)..

I want to ask you, why this approach doesn't work?
it seems to have no effect on the CPU usage.

this is the original code for one of the most time-consuming tasks:

for (Colony& colony : colonies)
{
    colony.update(dt, world);
}

and this is what I done:

for_each(std::execution::par,colonies.begin(), colonies.end(),
        [&dt, this](Colony& colony){
             colony.update(dt, world);
         });

May I have your opinion?

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