Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 858
    • Issues 858
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 57
    • Merge requests 57
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Merge requests
  • !2803

Draft: glib/tests/thread-pool-slow: Ensure other threads can run while waiting

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Marco Trevisan requested to merge 3v1n0/glib:thread-pool-slow-starving-fix into main Jul 09, 2022
  • Overview 3
  • Commits 1
  • Pipelines 1
  • Changes 1

In order to avoid possibly failures we are now waiting for all threads to have completed before stopping the unused ones, however we're waiting using a sleep call that may actually make the waiting threads not have the opportunity to run, leaving us just waiting indefinitely.

To avoid this, let's instead yield to give the waiting threads a chance to run while we're waiting.

Fixes: #2685 (closed)

--

It seems that same could be achieved by just iterating (i.e. while ((guint) g_atomic_int_get (&n_threads_executed) < limit) \n ;), but I think this is more correct, as even a simple busy-loop could lead to hit the same situation.

Edited Jul 10, 2022 by Marco Trevisan
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: thread-pool-slow-starving-fix