mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
Simplify list of workers in ThumbnailGenerator with unique_ptrs
This commit is contained in:
parent
f0a7d1faaa
commit
78ec753a3c
@ -250,10 +250,8 @@ bool ThumbnailGenerator::checkWorkers()
|
||||
|
||||
for (WorkerList::iterator
|
||||
it=m_workers.begin(); it != m_workers.end(); ) {
|
||||
Worker* worker = *it;
|
||||
worker->updateProgress();
|
||||
if (worker->isDone()) {
|
||||
delete worker;
|
||||
(*it)->updateProgress();
|
||||
if ((*it)->isDone()) {
|
||||
it = m_workers.erase(it);
|
||||
}
|
||||
else {
|
||||
@ -334,7 +332,7 @@ void ThumbnailGenerator::stopAllWorkers()
|
||||
}
|
||||
|
||||
base::scoped_lock hold(m_workersAccess);
|
||||
for (auto worker : m_workers)
|
||||
for (const auto& worker : m_workers)
|
||||
worker->stop();
|
||||
}
|
||||
|
||||
@ -342,9 +340,7 @@ void ThumbnailGenerator::startWorker()
|
||||
{
|
||||
base::scoped_lock hold(m_workersAccess);
|
||||
if (m_workers.size() < m_maxWorkers) {
|
||||
std::unique_ptr<Worker> worker(new Worker(m_remainingItems));
|
||||
m_workers.push_back(worker.get());
|
||||
worker.release();
|
||||
m_workers.push_back(std::make_unique<Worker>(m_remainingItems));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -47,7 +47,8 @@ namespace app {
|
||||
void startWorker();
|
||||
|
||||
class Worker;
|
||||
typedef std::vector<Worker*> WorkerList;
|
||||
using WorkerPtr = std::unique_ptr<Worker>;
|
||||
using WorkerList = std::vector<WorkerPtr>;
|
||||
|
||||
struct Item {
|
||||
IFileItem* fileitem;
|
||||
|
Loading…
Reference in New Issue
Block a user