File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99namespace 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
Original file line number Diff line number Diff line change 99
1010namespace 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 ();
You can’t perform that action at this time.
0 commit comments