コード例 #1
0
ファイル: Cache.cpp プロジェクト: AubinMahe/dcrud
void Cache::refresh( void ) {
   {
      os::Synchronized sync( _localMutex );
      {
         os::Synchronized sync2( _toUpdateMutex );
         for( byteBuffersIter_t it = _toUpdate.begin(); it != _toUpdate.end(); ++it ) {
            io::ByteBuffer * update   = *it;
            GUID             id       = GUID   ::unserialize( *update );
            ClassID          classId  = ClassID::unserialize( *update );
            localIter_t      itemIter = _local.find( id );
            if( itemIter == _local.end()) {
               Shareable * item = _participant.newInstance( classId, *update );
               if( item ) {
                  item->_id.set( id );
                  _local[id] = item;
               }
               else {
                  fprintf( stderr, "Unknown %s of %s\n",
                     classId.toString().c_str(), id.toString().c_str());
               }
            }
            else if( ! _ownershipCheck || ! owns( id )) {
               itemIter->second->unserialize( *update );
            }
            delete update;
         }
         _toUpdate.clear();
      }
      {
         os::Synchronized sync3( _toDeleteMutex );
         for( guidsIter_t it = _toDelete.begin(); it != _toDelete.end(); ++it ) {
            _local.erase( *it );
         }
         _toDelete.clear();
      }
   }
}