forked from organicmaps/organicmaps
Build fixes
This commit is contained in:
parent
cc223b4afc
commit
be79e7763a
4 changed files with 77 additions and 1 deletions
|
@ -56,7 +56,7 @@ public:
|
|||
return m2::PointD(5000*km, 5000*km);
|
||||
if (type == m_TypeCity || type == m_TypeCityCapital)
|
||||
{
|
||||
double const radius = sqrt(feature.GetPopulation() / 3000);
|
||||
double const radius = sqrt(static_cast<double>(feature.GetPopulation() / 3000));
|
||||
return m2::PointD(radius*km, radius*km);
|
||||
}
|
||||
return m2::PointD(0, 0);
|
||||
|
|
21
platform/concurrent_runner.hpp
Normal file
21
platform/concurrent_runner.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include "../base/runner.hpp"
|
||||
|
||||
namespace threads
|
||||
{
|
||||
|
||||
/// @note All current implementations use one shared system pool
|
||||
class ConcurrentRunner : public IRunner
|
||||
{
|
||||
class Impl;
|
||||
Impl * m_pImpl;
|
||||
|
||||
public:
|
||||
ConcurrentRunner();
|
||||
virtual ~ConcurrentRunner();
|
||||
virtual void Run(RunnerFuncT f);
|
||||
virtual void Join();
|
||||
};
|
||||
|
||||
}
|
30
platform/platform_tests/concurrent_runner_test.cpp
Normal file
30
platform/platform_tests/concurrent_runner_test.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "../../testing/testing.hpp"
|
||||
|
||||
#include "../concurrent_runner.hpp"
|
||||
#include "../platform.hpp"
|
||||
|
||||
#include "../../base/logging.hpp"
|
||||
#include "../../base/mutex.hpp"
|
||||
|
||||
#include "../../std/bind.hpp"
|
||||
|
||||
int globalCounter = 0;
|
||||
|
||||
threads::Mutex m;
|
||||
|
||||
void f()
|
||||
{
|
||||
threads::MutexGuard g(m);
|
||||
++globalCounter;
|
||||
}
|
||||
|
||||
static const int MAX_THREADS = 20;
|
||||
|
||||
UNIT_TEST(ConcurrentRunnerSmoke)
|
||||
{
|
||||
threads::ConcurrentRunner r;
|
||||
for (int i = 0; i < MAX_THREADS; ++i)
|
||||
r.Run(&f);
|
||||
r.Join();
|
||||
TEST_EQUAL(globalCounter, MAX_THREADS, ());
|
||||
}
|
25
platform/qt_concurrent_runner.cpp
Normal file
25
platform/qt_concurrent_runner.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "concurrent_runner.hpp"
|
||||
|
||||
#include <QtCore/QtConcurrentRun>
|
||||
#include <QtCore/QThreadPool>
|
||||
|
||||
namespace threads
|
||||
{
|
||||
ConcurrentRunner::ConcurrentRunner()
|
||||
{
|
||||
}
|
||||
|
||||
ConcurrentRunner::~ConcurrentRunner()
|
||||
{
|
||||
}
|
||||
|
||||
void ConcurrentRunner::Run(RunnerFuncT f)
|
||||
{
|
||||
QtConcurrent::run(f);
|
||||
}
|
||||
|
||||
void ConcurrentRunner::Join()
|
||||
{
|
||||
QThreadPool::globalInstance()->waitForDone();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue