22
22
namespace clang {
23
23
namespace mrdox {
24
24
25
+ class MRDOX_DECL
26
+ ExecutorGroupBase
27
+ {
28
+ protected:
29
+ struct MRDOX_DECL
30
+ AnyAgent
31
+ {
32
+ virtual ~AnyAgent () = 0 ;
33
+ virtual void * get () noexcept = 0;
34
+ };
35
+
36
+ public:
37
+ };
38
+
25
39
/* * A set of execution agents for performing concurrent work.
26
40
*/
27
41
template <class Agent >
28
- class ExecutorGroup
42
+ class ExecutorGroup : public ExecutorGroupBase
29
43
{
30
44
struct Impl
31
45
{
@@ -124,7 +138,6 @@ class ExecutorGroup
124
138
: group_(group)
125
139
, agent_(std::move(agent))
126
140
{
127
- MRDOX_ASSERT (agent_.get () != nullptr );
128
141
}
129
142
130
143
~scoped_agent ()
@@ -136,32 +149,28 @@ class ExecutorGroup
136
149
137
150
Agent& operator *() const noexcept
138
151
{
139
- MRDOX_ASSERT (agent_.get () != nullptr );
140
152
return *agent_;
141
153
}
142
154
};
143
155
144
156
void
145
157
run (std::unique_lock<std::mutex> lock)
146
158
{
147
- MRDOX_ASSERT (lock.owns_lock ());
148
159
std::unique_ptr<Agent> agent (std::move (agents_.back ()));
149
- MRDOX_ASSERT (agent.get () != nullptr );
150
160
agents_.pop_back ();
151
161
++busy_;
152
162
153
163
threadPool_.async (
154
164
[this , agent = std::move (agent)]() mutable
155
165
{
156
- MRDOX_ASSERT (agent.get () != nullptr );
157
- scoped_agent scope (*this , std::move (agent));
158
- MRDOX_ASSERT (agent.get () == nullptr );
159
166
std::unique_lock<std::mutex> lock (impl_->mutex_ );
167
+ scoped_agent scope (*this , std::move (agent));
160
168
for (;;)
161
169
{
162
170
if (work_.empty ())
163
171
break ;
164
- any_callable<void (Agent&)> work (std::move (work_.front ()));
172
+ any_callable<void (Agent&)> work (
173
+ std::move (work_.front ()));
165
174
work_.pop_front ();
166
175
unlock_guard unlock (impl_->mutex_ );
167
176
work (*scope);
0 commit comments