mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-20 17:51:19 -05:00
TileProviderManager owns a common thread pool for all TileProviders
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ThreadPool TileProviderManager::tileRequestThreadPool(1);
|
||||
|
||||
TileProviderManager::TileProviderManager()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
/*
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -121,7 +121,6 @@ namespace openspace {
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Member variables //
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user