ThreadPool changed from 3party/ThreadPool to PrimitiveThreadPool.

This commit is contained in:
Maksim Andrianov 2019-01-16 19:11:10 +03:00 committed by mpimenov
parent 8c987b3ab4
commit 2d1e1aa5ff
3 changed files with 9 additions and 12 deletions

View file

@ -11,6 +11,7 @@
#include "base/assert.hpp"
#include "base/geo_object_id.hpp"
#include "base/primitive_thread_pool.hpp"
#include <algorithm>
#include <functional>
@ -18,8 +19,6 @@
#include <limits>
#include <memory>
#include "3party/ThreadPool/ThreadPool.h"
namespace generator
{
namespace popularity
@ -269,11 +268,11 @@ std::vector<PopularityLine> BuildPopularitySrcFromAllData(std::vector<std::strin
{
CHECK_GREATER(cpuCount, 0, ());
ThreadPool threadPool(cpuCount);
threads::PrimitiveThreadPool threadPool(cpuCount);
std::vector<std::future<std::vector<PopularityLine>>> futures;
for (auto const & filename : dataFilenames)
{
auto result = threadPool.enqueue(
auto result = threadPool.Submit(
static_cast<std::vector<PopularityLine>(*)(std::string const &)>(BuildPopularitySrcFromData),
filename);
futures.emplace_back(std::move(result));

View file

@ -1,6 +1,7 @@
#include "generator/regions/regions_builder.hpp"
#include "base/assert.hpp"
#include "base/primitive_thread_pool.hpp"
#include "base/stl_helpers.hpp"
#include <algorithm>
@ -12,8 +13,6 @@
#include <thread>
#include <unordered_set>
#include "3party/ThreadPool/ThreadPool.h"
namespace generator
{
namespace regions
@ -32,7 +31,7 @@ Node::Ptr ShrinkToFit(Node::Ptr p)
RegionsBuilder::RegionsBuilder(Regions && regions,
std::unique_ptr<ToStringPolicyInterface> toStringPolicy,
int cpuCount)
size_t cpuCount)
: m_toStringPolicy(std::move(toStringPolicy))
, m_regions(std::move(regions))
, m_cpuCount(cpuCount)
@ -48,7 +47,7 @@ RegionsBuilder::RegionsBuilder(Regions && regions,
std::sort(std::begin(m_countries), std::end(m_countries), cmp);
}
RegionsBuilder::RegionsBuilder(Regions && regions, int cpuCount)
RegionsBuilder::RegionsBuilder(Regions && regions, size_t cpuCount)
: RegionsBuilder(std::move(regions), std::make_unique<JsonPolicy>(), cpuCount) {}
RegionsBuilder::Regions const & RegionsBuilder::GetCountries() const

View file

@ -27,8 +27,8 @@ public:
explicit RegionsBuilder(Regions && regions,
std::unique_ptr<ToStringPolicyInterface> toStringPolicy,
int cpuCount = -1);
explicit RegionsBuilder(Regions && regions, int cpuCount = -1);
size_t cpuCount = 1);
explicit RegionsBuilder(Regions && regions, size_t cpuCount = 1);
Regions const & GetCountries() const;
StringsList GetCountryNames() const;
@ -42,8 +42,7 @@ private:
std::unique_ptr<ToStringPolicyInterface> m_toStringPolicy;
Regions m_countries;
Regions m_regions;
int m_cpuCount;
size_t m_cpuCount;
};
} // namespace regions
} // namespace generator