Blender V5.0
util_task_test.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include <gtest/gtest.h>
6
7#include "util/task.h"
8
10
11namespace {
12
13void task_run() {}
14
15} // namespace
16
17TEST(util_task, basic)
18{
20 TaskPool pool;
21 for (int i = 0; i < 100; ++i) {
22 pool.push([] { task_run(); });
23 }
24 TaskPool::Summary summary;
25 pool.wait_work(&summary);
27 EXPECT_EQ(summary.num_tasks_handled, 100);
28}
29
30TEST(util_task, multiple_times)
31{
32 for (int N = 0; N < 1000; ++N) {
34 TaskPool pool;
35 for (int i = 0; i < 100; ++i) {
36 pool.push([] { task_run(); });
37 }
38 TaskPool::Summary summary;
39 pool.wait_work(&summary);
41 EXPECT_EQ(summary.num_tasks_handled, 100);
42 }
43}
44
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
static void exit()
Definition task.cpp:81
static void init(const int num_threads=0)
Definition task.cpp:60
#define CCL_NAMESPACE_END
#define N
int num_tasks_handled
Definition task.h:35
void push(TaskRunFunction &&task)
Definition task.cpp:21
void wait_work(Summary *stats=nullptr)
Definition task.cpp:27
i
Definition text_draw.cc:230
TEST(util_task, basic)