Lines Matching +full:queue +full:- +full:group
1 //==-- llvm/Support/ThreadPool.cpp - A ThreadPool implementation -*- C++ -*-==//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
15 #include "llvm/Config/llvm-config.h"
25 // A note on thread groups: Tasks are by default in no group (represented
26 // by nullptr ThreadPoolTaskGroup pointer in the Tasks queue) and functionality
27 // here normally works on all tasks regardless of their group (functions
29 // A task in a group has a pointer to that ThreadPoolTaskGroup in the Tasks
30 // queue, and functions called to work only on tasks from one group take that
46 set_thread_name(formatv("llvm-worker-{0}", ThreadID)); in grow()
54 // The group of the tasks run by the current thread.
59 // WaitingForGroup == nullptr means all tasks regardless of their group.
67 // Wait for tasks to be pushed in the queue in processTasks()
79 // Yeah, we have a task, grab it and release the lock on the queue in processTasks()
81 // We first need to signal that we are active before popping the queue in processTasks()
82 // in order for wait() to properly detect that even if the queue is in processTasks()
87 // Need to count active threads in each group separately, ActiveThreads in processTasks()
88 // would never be 0 if waiting for another group inside a wait. in processTasks()
96 CurrentThreadTaskGroups->push_back(GroupOfTask); in processTasks()
103 CurrentThreadTaskGroups->pop_back(); in processTasks()
104 if (CurrentThreadTaskGroups->empty()) { in processTasks()
115 --ActiveThreads; in processTasks()
118 if (--(A->second) == 0) in processTasks()
128 // If this was a task in a group, notify also threads waiting for tasks in processTasks()
130 // after the group it's been waiting for has finished. in processTasks()
136 bool StdThreadPool::workCompletedUnlocked(ThreadPoolTaskGroup *Group) const { in workCompletedUnlocked()
137 if (Group == nullptr) in workCompletedUnlocked()
139 return ActiveGroups.count(Group) == 0 && in workCompletedUnlocked()
141 [Group](const auto &T) { return T.second == Group; }); in workCompletedUnlocked()
146 // Wait for all threads to complete and the queue to be empty in wait()
152 void StdThreadPool::wait(ThreadPoolTaskGroup &Group) { in wait() argument
153 // Wait for all threads in the group to complete. in wait()
157 [&] { return workCompletedUnlocked(&Group); }); in wait()
162 !llvm::is_contained(*CurrentThreadTaskGroups, &Group)); in wait()
163 // Handle the case of recursive call from another task in a different group, in wait()
166 processTasks(&Group); in wait()
212 // is already removed from the queue). in wait()