1
0
Fork 0

We can't remove ssg branches in the threaded tile page because if we happen

to have attached an ssg loaded object to this branch, then plib will remove
it and all it's states (and textures) which will call opengl api commands
which will crash the program if run from a separate thread from the main render
thread.
This commit is contained in:
curt 2001-05-20 06:49:06 +00:00
parent 34854ab2af
commit 2afcbb4bc8
6 changed files with 20 additions and 4 deletions

View file

@ -89,6 +89,7 @@ FGTileLoader::add( FGTileEntry* tile )
tile_load_queue.push( tile );
}
#ifdef WISH_PLIB_WAS_THREADED // but it isn't
/**
*
*/
@ -97,6 +98,7 @@ FGTileLoader::remove( FGTileEntry* tile )
{
tile_free_queue.push( tile );
}
#endif
/**
*
@ -156,6 +158,7 @@ FGTileLoader::LoaderThread::run()
FGTileMgr::ready_to_attach( tile );
#ifdef WISH_PLIB_WAS_THREADED // but it isn't
// Handle and pending removals
while ( !loader->tile_free_queue.empty() ) {
cout << "freeing next tile ..." << endl;
@ -164,6 +167,8 @@ FGTileLoader::LoaderThread::run()
tile->free_tile();
delete tile;
}
#endif
}
pthread_cleanup_pop(1);
}

View file

@ -60,11 +60,13 @@ public:
*/
void add( FGTileEntry* tile );
#ifdef WISH_PLIB_WAS_THREADED // but it isn't
/**
* Remove a tile from memory.
* @param tile The tile to be removed from memory.
*/
void remove( FGTileEntry* tile );
#endif
/**
* The tile loader thread will only load one tile per call to the
@ -89,10 +91,10 @@ private:
* FIFO queue of tiles to load from data files.
*/
SGBlockingQueue< FGTileEntry * > tile_load_queue;
SGBlockingQueue< FGTileEntry * > tile_free_queue;
// SGBlockingQueue< FGTileEntry * > tile_free_queue;
#else
queue< FGTileEntry * > tile_load_queue;
queue< FGTileEntry * > tile_free_queue;
// queue< FGTileEntry * > tile_free_queue;
#endif
/**

View file

@ -64,9 +64,10 @@ void FGNewCache::entry_free( long cache_index ) {
SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING CACHE ENTRY = " << cache_index );
FGTileEntry *tile = tile_cache[cache_index];
tile->disconnect_ssg_nodes();
tile->sched_removal();
#if 0
#ifdef WISH_PLIB_WAS_THREADED
tile->sched_removal();
#else // plib isn't threaded so we always go here
tile->free_tile();
delete tile;
#endif

View file

@ -105,11 +105,15 @@ static void my_remove_branch( ssgBranch * branch ) {
}
#ifdef WISH_PLIB_WAS_THREADED // but it isn't
// Schedule tile to be freed/removed
void FGTileEntry::sched_removal() {
global_tile_mgr.ready_to_delete( this );
}
#endif
// Clean up the memory used by this tile and delete the arrays used by
// ssg as well as the whole ssg branch

View file

@ -177,8 +177,10 @@ public:
// Destructor
~FGTileEntry();
#ifdef WISH_PLIB_WAS_THREADED // but it isn't
// Schedule tile to be freed/removed
void sched_removal();
#endif
// Clean up the memory used by this tile and delete the arrays
// used by ssg as well as the whole ssg branch

View file

@ -143,10 +143,12 @@ public:
*/
static void ready_to_attach( FGTileEntry *t ) { attach_queue.push( t ); }
#ifdef WISH_PLIB_WAS_THREADED // but it isn't
/**
* Tile is detatched from scene graph and is ready to delete
*/
inline void ready_to_delete( FGTileEntry *t ) { loader.remove( t ); }
#endif
/**
* Add a pending model to the 'deferred model load' queue