blob: 647d96c901135e272e0680c70a00ada2f61e0696 (
plain) (
blame)
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
47
48
49
50
51
52
53
54
55
56
57
|
#include "factory.h"
#include "pool.h"
#include <library/cpp/testing/unittest/registar.h>
class TThrPoolTest: public TTestBase {
UNIT_TEST_SUITE(TThrPoolTest);
UNIT_TEST(TestSystemPool)
UNIT_TEST(TestAdaptivePool)
UNIT_TEST_SUITE_END();
struct TRunAble: public IThreadFactory::IThreadAble {
inline TRunAble()
: done(false)
{
}
~TRunAble() override = default;
void DoExecute() override {
done = true;
}
bool done;
};
private:
inline void TestSystemPool() {
TRunAble r;
{
THolder<IThreadFactory::IThread> thr = SystemThreadFactory()->Run(&r);
thr->Join();
}
UNIT_ASSERT_EQUAL(r.done, true);
}
inline void TestAdaptivePool() {
TRunAble r;
{
TAdaptiveThreadPool pool;
pool.Start(0);
THolder<IThreadFactory::IThread> thr = pool.Run(&r);
thr->Join();
}
UNIT_ASSERT_EQUAL(r.done, true);
}
};
UNIT_TEST_SUITE_REGISTRATION(TThrPoolTest);
|