-
Notifications
You must be signed in to change notification settings - Fork 42
/
thread_pool_mgr.h
55 lines (45 loc) · 1.26 KB
/
thread_pool_mgr.h
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#pragma once
// STD
#include <cstddef>
// APSI
#include "apsi/util/thread_pool.h"
namespace apsi {
/**
Manages lifetime of a static thread pool. While an instance of this class exists,
a static thread pool will be shared among all instances.
*/
class ThreadPoolMgr {
public:
/**
Build an instance of ThreadPoolMgr
*/
ThreadPoolMgr();
/**
Destructor for ThreadPoolMgr
*/
~ThreadPoolMgr();
/**
Get the thread pool managed by the thread pool manager
*/
util::ThreadPool &thread_pool() const;
/**
Set the number of threads to be used by the thread pool
*/
static void SetThreadCount(std::size_t threads);
/**
This method is to be used explicitly by tests.
*/
static void SetPhysThreadCount(std::size_t threads);
/**
Get the number of threads used by the thread pool
*/
static std::size_t GetThreadCount();
private:
/**
Reference count to manage lifetime of the static thread pool
*/
static std::size_t ref_count_;
};
} // namespace apsi