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

Allow for waiting threads to do jobs #18

Open
pplux opened this issue Oct 19, 2020 · 1 comment
Open

Allow for waiting threads to do jobs #18

pplux opened this issue Oct 19, 2020 · 1 comment
Labels
enhancement New feature or request
Projects

Comments

@pplux
Copy link
Owner

pplux commented Oct 19, 2020

Pseudo code:

        px_sched::Sync sync;
        for(int i = 0; i < 100; ++i) {
            scheduler.runTask([&](){
                // Heavy task
                }, &sync);
        }
        scheduler.waitFor(sync);

Here the calling thread that creates the task will suspend waiting for the tasks to be finished before carrying on. This requires the pool of threads to be bigger than the actual core count to allow some threads wait for others and still have enough threads to keep using all cpus. One possible solution could be for the thread that waits on a sync object to start doing tasks from the list of tasks related to that sync object.

The idea is that if the thread needs to wait for a task to be finished it can go on and start working on that lists of tasks itself instead of waiting.

@pplux pplux added the enhancement New feature or request label Oct 19, 2020
@rokups
Copy link

rokups commented Nov 4, 2020

I recently was scouting source of px looking whether this implemented and was considering posting a suggestion. This would be a very useful feature to have. Thank you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
px_sched
Awaiting triage
Development

No branches or pull requests

2 participants