mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 11:04:25 -04:00
Remove ConcurrentQueue::joinAll()
This function is called only from ~ConcurrentQueue(). joinAll() is not thread-safe and it cannot be called earlier without introducing a null state. Moving the function's implementation into the definition of ~ConcurrentQueue() makes the code clearer. Removing joinAll() also allows to establish and document invariants for two data members. Assert consistency between jobsLeft and _queue in ~ConcurrentQueue().
This commit is contained in:
committed by
Luis Ángel San Martín
parent
61cd245037
commit
4cb542c8cc
@ -36,10 +36,11 @@ public:
|
||||
void waitAll();
|
||||
|
||||
private:
|
||||
//! @invariant all worker threads are joinable until the destructor is called.
|
||||
std::vector<std::thread> threads;
|
||||
std::queue<Job> _queue;
|
||||
std::size_t jobsLeft = 0; //!< @invariant jobsLeft >= _queue.size()
|
||||
bool bailout = false;
|
||||
bool bailout = false; //!< @invariant is false until the destructor is called.
|
||||
std::condition_variable jobAvailableVar;
|
||||
std::condition_variable _waitVar;
|
||||
std::mutex jobsLeftMutex;
|
||||
@ -47,7 +48,6 @@ private:
|
||||
|
||||
void nextJob();
|
||||
void finalizeJobs(std::size_t count);
|
||||
void joinAll();
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user