Welcome to mirror list, hosted at ThFree Co, Russian Federation.

util_task_test.cpp « test « cycles « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fe4e09f3b9866cdd6f24a9ae6a6a287984de83f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* SPDX-License-Identifier: Apache-2.0
 * Copyright 2011-2022 Blender Foundation */

#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(function_bind(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(function_bind(task_run));
    }
    TaskPool::Summary summary;
    pool.wait_work(&summary);
    TaskScheduler::exit();
    EXPECT_EQ(summary.num_tasks_handled, 100);
  }
}

CCL_NAMESPACE_END