Sitelet https://github.com/Fdhvdu/ThreadPool/commit/6fdd41bd5984d4aee1da2e9f821acc55f0ef4585
Skip to content

Commit 6fdd41b

Browse files
committed
add comment
1 parent c277935 commit 6fdd41b

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎header/CThreadPool.hpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
namespace nThread
1010
{
11-
class CThreadPool //cannot return value
11+
//1. a fixed-sized threadpool
12+
//2. cannot return value
13+
class CThreadPool
1214
{
1315
public:
1416
typedef std::thread::id thread_id;
@@ -18,8 +20,7 @@ namespace nThread
1820
thread_id add_(std::function<void()> &&);
1921
void add_and_detach_(std::function<void()> &&);
2022
public:
21-
//1. determine how many threads you want to use
22-
//2. the value you pass will always equal to count
23+
//determine how many threads you want to use
2324
explicit CThreadPool(std::size_t);
2425
//of course, why do you need to copy or move CThreadPool?
2526
CThreadPool(const CThreadPool &)=delete;
@@ -51,7 +52,7 @@ namespace nThread
5152
//2. reduce 1 after calling add or add_and_detach
5253
std::size_t available() const noexcept;
5354
//1. return total threads can be used
54-
//2. the return value is what you pass to constructor
55+
//2. the count is fixed after constructing
5556
std::size_t count() const noexcept;
5657
//do not combine join and join_any together in your code
5758
//it will make some join_any cannot get notification

‎header/CThreadPool_Ret.hpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
namespace nThread
1111
{
12+
//1. a fixed-sized threadpool
13+
//2. can return value
1214
template<class Ret>
13-
class CThreadPool_Ret //can return value
15+
class CThreadPool_Ret
1416
{
1517
public:
1618
typedef std::thread::id thread_id;
@@ -54,7 +56,7 @@ namespace nThread
5456
return waitingQue_.size();
5557
}
5658
//1. return total threads can be used
57-
//2. the return value is what you pass to constructor
59+
//2. the count is fixed after constructing
5860
inline std::size_t count() const noexcept
5961
{
6062
return thr_.size();

0 commit comments

Comments
 (0)