avoid push_back in loops
Detected by clang-tidy.
This commit is contained in:
parent
cf800a35da
commit
79409eb6fe
@ -34,14 +34,12 @@ main (void)
|
|||||||
{
|
{
|
||||||
util::job::queue q {std::thread::hardware_concurrency (), INNER};
|
util::job::queue q {std::thread::hardware_concurrency (), INNER};
|
||||||
std::vector<util::job::queue::cookie> cookies;
|
std::vector<util::job::queue::cookie> cookies;
|
||||||
for (int j = 0; j < INNER; ++j) {
|
std::generate_n (std::back_inserter (cookies), INNER, [&] () {
|
||||||
cookies.push_back (
|
return q.submit (
|
||||||
q.submit (
|
sleep_inc,
|
||||||
sleep_inc,
|
std::ref (count)
|
||||||
std::ref (count)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
success = count == INNER && success;
|
success = count == INNER && success;
|
||||||
|
@ -60,8 +60,13 @@ main ()
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::thread> workers;
|
std::vector<std::thread> workers;
|
||||||
for (int i = 0; i < parallelism; ++i)
|
std::generate_n (
|
||||||
workers.emplace_back (func, i);
|
std::back_inserter (workers),
|
||||||
|
parallelism,
|
||||||
|
[&, i = 0] () mutable
|
||||||
|
{
|
||||||
|
return std::thread { func, i++ };
|
||||||
|
});
|
||||||
|
|
||||||
for (auto &t: workers)
|
for (auto &t: workers)
|
||||||
t.join ();
|
t.join ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user