Blender V4.3
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 "testing/testing.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(function_bind(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(function_bind(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:82
static void init(int num_threads=0)
Definition task.cpp:61
#define function_bind
#define CCL_NAMESPACE_END
#define N
int num_tasks_handled
Definition task.h:36
void push(TaskRunFunction &&task)
Definition task.cpp:22
void wait_work(Summary *stats=NULL)
Definition task.cpp:28
TEST(util_task, basic)