Blender
V5.0
intern
cycles
test
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
9
CCL_NAMESPACE_BEGIN
10
11
namespace
{
12
13
void
task_run
() {}
14
15
}
// namespace
16
17
TEST
(util_task, basic)
18
{
19
TaskScheduler::init
(0);
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);
26
TaskScheduler::exit
();
27
EXPECT_EQ
(summary.
num_tasks_handled
, 100);
28
}
29
30
TEST
(util_task, multiple_times)
31
{
32
for
(
int
N
= 0;
N
< 1000; ++
N
) {
33
TaskScheduler::init
(0);
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);
40
TaskScheduler::exit
();
41
EXPECT_EQ
(summary.
num_tasks_handled
, 100);
42
}
43
}
44
45
CCL_NAMESPACE_END
EXPECT_EQ
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
TaskScheduler::exit
static void exit()
Definition
task.cpp:81
TaskScheduler::init
static void init(const int num_threads=0)
Definition
task.cpp:60
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
N
#define N
Definition
mball_tessellate.cc:275
CCL_NAMESPACE_BEGIN
Definition
python.cpp:37
CCL_NAMESPACE_BEGIN::task_run
void task_run()
Definition
util_task_test.cpp:13
TaskPool::Summary
Definition
task.h:30
TaskPool::Summary::num_tasks_handled
int num_tasks_handled
Definition
task.h:35
TaskPool
Definition
task_pool.cc:157
TaskPool::push
void push(TaskRunFunction &&task)
Definition
task.cpp:21
TaskPool::wait_work
void wait_work(Summary *stats=nullptr)
Definition
task.cpp:27
task.h
i
i
Definition
text_draw.cc:230
TEST
TEST(util_task, basic)
Definition
util_task_test.cpp:17
Generated on
for Blender by
doxygen
1.16.1