mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
ConcurrentQueue: simplify the constructor implementation
* threadCount argument: int => std::size_t to avoid implicit casting; * eliminate temporary empty std::thread objects; * replace a trivial lambda with a function pointer and its argument; * get rid of the unused dedicated loop counter.
This commit is contained in:
parent
c333fbc7d0
commit
2655613543
@ -14,16 +14,13 @@ namespace YACReader {
|
||||
class ConcurrentQueue
|
||||
{
|
||||
public:
|
||||
explicit ConcurrentQueue(int threadCount)
|
||||
explicit ConcurrentQueue(std::size_t threadCount)
|
||||
: jobsLeft(0),
|
||||
bailout(false)
|
||||
{
|
||||
threads = std::vector<std::thread>(threadCount);
|
||||
for (int index = 0; index < threadCount; ++index) {
|
||||
threads[index] = std::thread([this] {
|
||||
this->nextJob();
|
||||
});
|
||||
}
|
||||
threads.reserve(threadCount);
|
||||
for (; threadCount != 0; --threadCount)
|
||||
threads.emplace_back(&ConcurrentQueue::nextJob, this);
|
||||
}
|
||||
|
||||
~ConcurrentQueue()
|
||||
|
Loading…
x
Reference in New Issue
Block a user