osgEarth 2.1.1
Public Member Functions

ParallelKeyNodeFactory Class Reference

Inheritance diagram for ParallelKeyNodeFactory:
Collaboration diagram for ParallelKeyNodeFactory:

List of all members.

Public Member Functions

 ParallelKeyNodeFactory (TileBuilder *builder, const OSGTerrainOptions &options, const MapInfo &mapInfo, Terrain *terrain, UID engineUID)
osg::Node * createNode (const TileKey &key)

Detailed Description

Definition at line 27 of file ParallelKeyNodeFactory.


Constructor & Destructor Documentation

ParallelKeyNodeFactory::ParallelKeyNodeFactory ( TileBuilder builder,
const OSGTerrainOptions options,
const MapInfo mapInfo,
Terrain terrain,
UID  engineUID 
)

Definition at line 30 of file ParallelKeyNodeFactory.cpp.

                                                                                    :

SerialKeyNodeFactory( builder, options, mapInfo, terrain, engineUID )
{
    //NOP
}

Member Function Documentation

osg::Node * ParallelKeyNodeFactory::createNode ( const TileKey key) [virtual]

Reimplemented from SerialKeyNodeFactory.

Definition at line 42 of file ParallelKeyNodeFactory.cpp.

{
    // An event for synchronizing the completion of all requests:
    Threading::MultiEvent semaphore;

    // Collect all the jobs that can run in parallel (from all 4 subtiles)
    osg::ref_ptr<TileBuilder::Job> jobs[4];
    unsigned numTasks = 0;
    for( unsigned i=0; i<4; ++i )
    {
        jobs[i] = _builder->createJob( key.createChildKey(i), semaphore );
        if ( jobs[i].valid() )
            numTasks += jobs[i]->_tasks.size();
    }

    // Set up the sempahore to block for the correct number of tasks:
    semaphore.reset( numTasks );

    // Run all the tasks in parallel:
    for( unsigned i=0; i<4; ++i )
        if ( jobs[i].valid() )
            _builder->runJob( jobs[i].get() );

    // Wait for them to complete:
    semaphore.wait();

    // Now postprocess them and assemble into a tile group.
    osg::Group* root = new osg::Group();

    for( unsigned i=0; i<4; ++i )
    {
        if ( jobs[i].valid() )
        {
            osg::ref_ptr<Tile> tile;
            bool hasRealData;
            bool hasLodBlending;
            _builder->finalizeJob( jobs[i].get(), tile, hasRealData, hasLodBlending );
            if ( tile.valid() )
                addTile( tile.get(), hasRealData, hasLodBlending, root );
        }
    }

    //TODO: need to check to see if the group is empty, and do something different.
    return root;
}

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines