a newly loaded tile to the scene graph. Instead it puts it in a queue
for the tile manager. I've used your counter_hack to check the loaded
queue and add any tiles to the scene graph. I was playing around with
the counter_hack so there might be some commented out code, etc. I also
changed some SG_DEBUGs to SG_INFOs so I could track the tile loading.
He writes:
Here are the final changes to add threads to the tile loading. All the
thread related code is in the new FGTileLoader class.
./configure.in
./acconfig.h
Added --with-threads option and corresponding ENABLE_THREADS
definition. The default is no threads.
./src/Scenery/tilemgr
Removed load_queue and associated references. This has been replaced by
a new class FGTileLoader in FGNewCache.
Made the global variable global_tile_cache a member.
schedule_needed(): removed global_tile_cache.exists() tests since
sched_tile() effectively repeats the test.
initialize_queue(): removed code that loads tiles since this is now
performed by FGTileLoader.
update(): ditto
./src/Scenery/newcache
Added new class FGTileLoader to manage tile queuing and loading.
tile_map typedefs are private.
exists() is a const member function.
fill_in(): deleted
load_tile(): added.
./src/Scenery/FGTileLoader
The new threaded tile loader. Maintains a queue of tiles waiting to be
loaded and an array of one or more threads to load the tiles. Currently
only a single thread is created. The queue is guarded by a mutex to
synchronize access. A condition variable signals the thread when the
queue is non-empty.
CLO: I made a few tweaks to address a couple issues, hopefully what we
have is solid, but now we kick it out to the general public to see. :-)
tile has been loaded. Since this flag can be set by another thread I've
declared it "volatile bool".
Also cleaned up delete vs delete[] usage. Gcc is happy with delete[],
which is the correct usage.
The files in the attached tarball make the following changes to
FlightGear:
- rename the existing FGInterface::init() method to
FGInterface::_setup to get it out of the way
- move *all* FDM initialization code out of src/Main/fg_init.cxx and
into FGInterface::init(), and clean up fg_init.cxx a little
(especially by removing the zillions of attempts to place the plane on
the ground at various locations in the code)
- modify FGInterface::bind() so that no values are picked up
automatically at bind time (they are set previously by init() instead)
- modify the init() methods of the classes derived from FGInterface
(i.e. larcsim, jsbsim, balloon, magic, and ada) to invoke
FGInterface::init() explicitly before doing their own setup
I don't claim that the code in FGInterface::init() is optimal (or even
correct), but it seems to work for on-ground starts with both LaRCSim
and JSBSim on runways pointing various directions from near sea level
to about 700' ASL (the range I happened to test). I expect that Jon
and Tony will want to look at the code and refactor and correct it now
that they can see what's going on in one place.
Here's a quick outline of what is invoked:
cur_fdm_state = new <whatever>(dt);
cur_fdm_state->init();
cur_fdm_state->bind();
The constructor allocates memory and sets default values only (with
the help of the FGInterface::_setup() method). The init() method pull
any required properties out of the property tree and sets up the
initial state of the FDM. The bind() method takes ownership of
FDM-related properties so that the FDM can publish them to the rest of
the sim.
Note that bind() and init() are virtual, so any implementation in a
subclass will hide the implementation in FGInterface; that's why
subclass implementations of init() and bind() have to invoke
FGInterface::init() and FGInterface::bind() explicitly, probably at
the start, so that they get the basic initialization.
hope, with earlier versions as well)
- support for the new LONG value type
- gear support for UIUC (updated for the newly renamed SG_* stuff;
otherwise identical to what I sent you before)
- fixed reported MSVC problem in src/FDM/flight.cxx