throttled to one tile per frame maximum.
beenhere = true;
}
-#ifdef ENABLE_THREADS
- tile_queue.push( tile );
-#else
- tile->load( tile_path, true );
- tile->add_ssg_nodes( terrain, ground );
-#endif // ENABLE_THREADS
+ tile_load_queue.push( tile );
}
/**
FGTileLoader::update()
{
#ifdef ENABLE_THREADS
+ // send a signal to the pager thread that it is allowed to load
+ // another tile
mutex.lock();
frame_cond.signal();
mutex.unlock();
+#else
+ if ( !tile_load_queue.empty() ) {
+ cout << "loading next tile ..." << endl;
+ // load the next tile in the queue
+ FGTileEntry* tile = tile_load_queue.front();
+ tile_load_queue.pop();
+ tile->load( tile_path, true );
+ FGTileMgr::loaded( tile );
+ }
#endif // ENABLE_THREADS
}
pthread_cleanup_push( cleanup_handler, loader );
while ( true ) {
// Wait for a load request to be placed in the queue.
- FGTileEntry* tile = loader->tile_queue.pop();
+ FGTileEntry* tile = loader->tile_load_queue.pop();
// Wait for the next frame signal before we load a tile from the queue
- // loader->mutex.lock();
- // loader->frame_cond.wait( loader->mutex );
- // loader->mutex.unlock();
+ loader->mutex.lock();
+ loader->frame_cond.wait( loader->mutex );
+ loader->mutex.unlock();
set_cancel( SGThread::CANCEL_DISABLE );
tile->load( loader->tile_path, true );
#ifdef ENABLE_THREADS
# include <simgear/threads/SGThread.hxx>
# include <simgear/threads/SGQueue.hxx>
+#else
+# include <queue>
#endif
// Forward reference.
* Returns whether the load queue is empty (contains no elements).
* @return true if load queue is empty otherwise returns false.
*/
- // bool empty() const { return tile_queue.empty(); }
+ // bool empty() const { return tile_load_queue.empty(); }
private:
/**
* FIFO queue of tiles to load from data files.
*/
- SGBlockingQueue< FGTileEntry* > tile_queue;
+ SGBlockingQueue< FGTileEntry* > tile_load_queue;
+#else
+ queue< FGTileEntry* > tile_load_queue;
#endif
/**
}
// load custom objects
- SG_LOG( SG_TERRAIN, SG_DEBUG, "CUSTOM OBJECTS" );
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "Checking for custom objects ..." );
SGPath index_path = tile_path;
index_path.append( index_str );
// load the object itself
SGPath custom_path = tile_path;
+ ssgTexturePath( (char *)custom_path.c_str() );
custom_path.append( name );
ssgEntity *obj_model = ssgLoad( (char *)custom_path.c_str() );
#ifdef ENABLE_THREADS
SGLockedQueue<FGTileEntry*> FGTileMgr::loaded_queue;
+#else
+queue<FGTileEntry*> FGTileMgr::loaded_queue;
#endif // ENABLE_THREADS
// Constructor
state = Running;
}
- // now handled by threaded tile pager
-#if 0
- if ( load_queue.size() ) {
- SG_LOG( SG_TERRAIN, SG_INFO, "Load queue size = " << load_queue.size()
- << " loading a tile" );
-
- SGBucket pending = load_queue.front();
- load_queue.pop_front();
- load_tile( pending );
- }
-#endif
+ // load the next tile in the load queue (or authorize the next
+ // load in the case of the threaded tile pager)
+ loader.update();
if ( scenery.center == Point3D(0.0) ) {
// initializing
// Notify the tile loader that it can load another tile
// loader.update();
+ if ( !loaded_queue.empty() ) {
#ifdef ENABLE_THREADS
- if (!loaded_queue.empty())
- {
FGTileEntry* e = loaded_queue.pop();
+#else
+ FGTileEntry* e = loaded_queue.front();
+ loaded_queue.pop();
+#endif
e->add_ssg_nodes( terrain, ground );
//std::cout << "Adding ssg nodes for "
//<< e->get_tile_bucket() << "\n";
}
-#endif // ENABLE_THREADS
}
return 1;
#include <simgear/compiler.h>
+#include <queue>
+
#include <plib/ssg.h>
#include <simgear/bucket/newbucket.hxx>
FGTileLoader loader;
int counter_hack;
-#ifdef ENABLE_THREADS
/**
* Tiles to add to scene graph.
*/
+#ifdef ENABLE_THREADS
static SGLockedQueue<FGTileEntry*> loaded_queue;
+#else
+ static queue<FGTileEntry*> loaded_queue;
+#endif // ENABLE_THREADS
public:
* Add a loaded tile to the scene graph queue.
*/
static void loaded( FGTileEntry* t ) { loaded_queue.push(t); }
-#endif // ENABLE_THREADS
public: