#include <atomic>
#include "gtest/gtest.h"
#include "misc_language.h"
#include "common/threadpool.h"
Go to the source code of this file.
|
| | TEST (threadpool, wait_nothing) |
| |
| | TEST (threadpool, wait_waits) |
| |
| | TEST (threadpool, one_thread) |
| |
| | TEST (threadpool, many_threads) |
| |
| | TEST (threadpool, reentrency) |
| |
| | TEST (threadpool, reentrancy) |
| |
| | TEST (threadpool, leaf_throws) |
| |
| | TEST (threadpool, leaf_reentrancy) |
| |
◆ TEST() [1/8]
| TEST |
( |
threadpool |
, |
|
|
wait_nothing |
|
|
) |
| |
◆ TEST() [2/8]
| TEST |
( |
threadpool |
, |
|
|
wait_waits |
|
|
) |
| |
Definition at line 41 of file threadpool.cpp.
45 std::atomic<bool> b(
false);
48 waiter.
wait(tpool.get());
#define ASSERT_FALSE(condition)
#define ASSERT_TRUE(condition)
◆ TEST() [3/8]
| TEST |
( |
threadpool |
, |
|
|
one_thread |
|
|
) |
| |
Definition at line 52 of file threadpool.cpp.
57 std::atomic<unsigned int> counter(0);
58 for (
size_t n = 0; n < 4096; ++n)
60 tpool->submit(&waiter, [&counter](){++counter;});
62 waiter.
wait(tpool.get());
#define ASSERT_EQ(val1, val2)
◆ TEST() [4/8]
| TEST |
( |
threadpool |
, |
|
|
many_threads |
|
|
) |
| |
Definition at line 66 of file threadpool.cpp.
71 std::atomic<unsigned int> counter(0);
72 for (
size_t n = 0; n < 4096; ++n)
74 tpool->submit(&waiter, [&counter](){++counter;});
76 waiter.
wait(tpool.get());
#define ASSERT_EQ(val1, val2)
◆ TEST() [5/8]
| TEST |
( |
threadpool |
, |
|
|
reentrency |
|
|
) |
| |
Definition at line 92 of file threadpool.cpp.
98 waiter.
wait(tpool.get());
#define ASSERT_EQ(val1, val2)
unsigned __int64 uint64_t
◆ TEST() [6/8]
| TEST |
( |
threadpool |
, |
|
|
reentrancy |
|
|
) |
| |
Definition at line 102 of file threadpool.cpp.
108 waiter.
wait(tpool.get());
#define ASSERT_EQ(val1, val2)
unsigned __int64 uint64_t
◆ TEST() [7/8]
| TEST |
( |
threadpool |
, |
|
|
leaf_throws |
|
|
) |
| |
Definition at line 112 of file threadpool.cpp.
117 bool thrown =
false, executed =
false;
118 tpool->submit(&waiter, [&](){
119 try { tpool->submit(&waiter, [&](){ executed =
true; }); }
120 catch(
const std::exception &e) { thrown =
true; }
122 waiter.
wait(tpool.get());
#define ASSERT_FALSE(condition)
#define ASSERT_TRUE(condition)
◆ TEST() [8/8]
| TEST |
( |
threadpool |
, |
|
|
leaf_reentrancy |
|
|
) |
| |
Definition at line 127 of file threadpool.cpp.
132 std::atomic<int> counter(0);
133 for (
int i = 0; i < 1000; ++i)
135 tpool->submit(&waiter, [&](){
137 for (
int j = 0; j < 500; ++j)
139 tpool->submit(&waiter, [&](){ ++counter; },
true);
141 waiter.
wait(tpool.get());
144 waiter.
wait(tpool.get());
#define ASSERT_EQ(val1, val2)