mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-30 15:54:13 +08:00
Avoid using std::vector whenever possible
This commit is contained in:
parent
65a7113a36
commit
6a31b7be3e
@ -27,7 +27,7 @@ class ThreadPoolInterface {
|
|||||||
class ThreadPool : public ThreadPoolInterface {
|
class ThreadPool : public ThreadPoolInterface {
|
||||||
public:
|
public:
|
||||||
// Construct a pool that contains "num_threads" threads.
|
// Construct a pool that contains "num_threads" threads.
|
||||||
explicit ThreadPool(int num_threads) {
|
explicit ThreadPool(int num_threads) : threads_(num_threads), waiting_(num_threads) {
|
||||||
for (int i = 0; i < num_threads; i++) {
|
for (int i = 0; i < num_threads; i++) {
|
||||||
threads_.push_back(new std::thread([this]() { WorkerLoop(); }));
|
threads_.push_back(new std::thread([this]() { WorkerLoop(); }));
|
||||||
}
|
}
|
||||||
@ -110,8 +110,8 @@ class ThreadPool : public ThreadPoolInterface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::mutex mu_;
|
std::mutex mu_;
|
||||||
std::vector<std::thread*> threads_; // All threads
|
MaxSizeVector<std::thread*> threads_; // All threads
|
||||||
std::vector<Waiter*> waiters_; // Stack of waiting threads.
|
MaxSizeVector<Waiter*> waiters_; // Stack of waiting threads.
|
||||||
std::deque<std::function<void()>> pending_; // Queue of pending work
|
std::deque<std::function<void()>> pending_; // Queue of pending work
|
||||||
std::condition_variable empty_; // Signaled on pending_.empty()
|
std::condition_variable empty_; // Signaled on pending_.empty()
|
||||||
bool exiting_ = false;
|
bool exiting_ = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user