Esempio n. 1
0
void VersionedSlaveCM::applyMapData( const uint128_t& version )
{
    while( true )
    {
        ObjectDataIStream* is = _queuedVersions.pop();
        if( is->getVersion() == version )
        {
            LBASSERTINFO( is->hasInstanceData(), *_object );

            if( is->hasData( )) // not VERSION_NONE
                _object->applyInstanceData( *is );
            _version = is->getVersion();

            LBASSERT( _version != VERSION_INVALID );
            LBASSERTINFO( !is->hasData(),
                          lunchbox::className( _object ) <<
                          " did not unpack all data, " <<
                          is->getRemainingBufferSize() << " bytes, " <<
                          is->nRemainingBuffers() << " buffer(s)" );

            _releaseStream( is );
#if 0
            LBLOG( LOG_OBJECTS ) << "Mapped initial data of " << _object
                                 << std::endl;
#endif
            return;
        }
        else
        {
            // Found the following case:
            // - p1, t1 calls commit
            // - p1, t2 calls mapObject
            // - p1, cmd commits new version
            // - p1, cmd subscribes object
            // - p1, rcv attaches object
            // - p1, cmd receives commit data
            // -> newly attached object recv new commit data before map data,
            //    ignore it
            LBASSERTINFO( is->getVersion() > version,
                          is->getVersion() << " <= " << version );
            _releaseStream( is );
        }
    }
}