TileProviderManager owns a common thread pool for all TileProviders

This commit is contained in:
Erik Broberg
2016-05-20 13:20:46 -04:00
parent bb551432e3
commit 8844775a1f
6 changed files with 11 additions and 5 deletions

View File

@@ -41,6 +41,7 @@
#include <modules/globebrowsing/geodetics/ellipsoid.h>
#include <modules/globebrowsing/other/tileprovidermanager.h>
#include <modules/globebrowsing/other/threadpool.h>
namespace ghoul {
namespace opengl {

View File

@@ -31,6 +31,7 @@ namespace {
namespace openspace {
ThreadPool TileProviderManager::tileRequestThreadPool(1);
TileProviderManager::TileProviderManager()
{

View File

@@ -40,6 +40,8 @@ namespace openspace {
TileProviderManager();
~TileProviderManager();
static ThreadPool tileRequestThreadPool;
void addHeightMap(std::string name, std::shared_ptr<TileProvider> tileProvider);
void addColorTexture(std::string name, std::shared_ptr<TileProvider> tileProvider);
/*

View File

@@ -33,6 +33,7 @@
#include <atomic>
#include <modules/globebrowsing/other/concurrentqueue.h>
#include <modules/globebrowsing/other/threadpool.h>
#include <ghoul/misc/assert.h>
@@ -64,7 +65,7 @@ namespace openspace {
template<typename P>
class ConcurrentJobManager{
public:
ConcurrentJobManager()
ConcurrentJobManager(ThreadPool& pool) : threadPool(pool)
{
}
@@ -75,14 +76,14 @@ namespace openspace {
void enqueueJob(std::shared_ptr<Job<P>> job) {
TileProvider::threadPool.enqueue([this, job]() {
threadPool.enqueue([this, job]() {
job->execute();
_finishedJobs.push(job);
});
}
void clearEnqueuedJobs() {
TileProvider::threadPool.clearTasks();
threadPool.clearTasks();
}
std::shared_ptr<Job<P>> popFinishedJob() {
@@ -99,7 +100,7 @@ namespace openspace {
private:
ConcurrentQueue<std::shared_ptr<Job<P>>> _finishedJobs;
ThreadPool& threadPool;
};

View File

@@ -24,6 +24,7 @@
#include <modules/globebrowsing/geodetics/geodetic2.h>
#include <modules/globebrowsing/other/tileprovider.h>
#include <modules/globebrowsing/other/tileprovidermanager.h>
#include <openspace/engine/downloadmanager.h>
@@ -57,6 +58,7 @@ namespace openspace {
, _tileCache(tileCacheSize) // setting cache size
, _framesSinceLastRequestFlush(0)
, _framesUntilRequestFlush(framesUntilRequestFlush)
, _tileLoadManager(TileProviderManager::tileRequestThreadPool)
{
// Set a temporary texture
std::string fileName = "textures/earth_bluemarble.jpg";

View File

@@ -121,7 +121,6 @@ namespace openspace {
//////////////////////////////////////////////////////////////////////////////////
// Member variables //
//////////////////////////////////////////////////////////////////////////////////