* Use .empty() and .data() * Use nullptr instead of 0 * No else after return * Simple class member initialization * Add override for virtual methods * Include C++ instead of C headers * Remove some unused includes * Use default constructors * Always use braces * Consistent names in definition and declaration * Change typedef to using Pull Request: https://projects.blender.org/blender/blender/pulls/132361
46 lines
853 B
C++
46 lines
853 B
C++
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#include "testing/testing.h"
|
|
|
|
#include "util/task.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
namespace {
|
|
|
|
void task_run() {}
|
|
|
|
} // namespace
|
|
|
|
TEST(util_task, basic)
|
|
{
|
|
TaskScheduler::init(0);
|
|
TaskPool pool;
|
|
for (int i = 0; i < 100; ++i) {
|
|
pool.push([] { task_run(); });
|
|
}
|
|
TaskPool::Summary summary;
|
|
pool.wait_work(&summary);
|
|
TaskScheduler::exit();
|
|
EXPECT_EQ(summary.num_tasks_handled, 100);
|
|
}
|
|
|
|
TEST(util_task, multiple_times)
|
|
{
|
|
for (int N = 0; N < 1000; ++N) {
|
|
TaskScheduler::init(0);
|
|
TaskPool pool;
|
|
for (int i = 0; i < 100; ++i) {
|
|
pool.push([] { task_run(); });
|
|
}
|
|
TaskPool::Summary summary;
|
|
pool.wait_work(&summary);
|
|
TaskScheduler::exit();
|
|
EXPECT_EQ(summary.num_tasks_handled, 100);
|
|
}
|
|
}
|
|
|
|
CCL_NAMESPACE_END
|