Show
Ignore:
Timestamp:
01/25/08 14:32:12 (1 year ago)
Author:
cneumann
Message:

fixed: MT sync for child fields (should not link parents)

more reliable thread exit for MT test

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Carsten_PtrWork2/Source/System/FieldContainer/Fields/OSGMChildFCPointerField.inl

    r1041 r1042  
    111111} 
    112112 
     113/*! Clears the field, adjusting the reference count of pointed to objects, but 
     114    NOT their parent links. 
     115 */ 
     116template <class ObjectT, Int32 NamespaceI, class AllocatorT> 
     117inline void 
     118MChildFCPointerField<ObjectT, NamespaceI, AllocatorT>::clearNoUnlink(void) 
     119{ 
     120    StorageIter vI = this->editRawStorage().begin(); 
     121    StorageIter vE = this->editRawStorage().end  (); 
     122     
     123    for(; vI != vE; ++vI) 
     124    { 
     125        decRefCount(*vI); 
     126    } 
     127     
     128    this->editRawStorage().clear(); 
     129} 
     130 
     131/*! Resizes the field, adjusting the reference count of pointed to objects, but 
     132    NOT their parent links. 
     133 */ 
     134template <class ObjectT, Int32 NamespaceI, class AllocatorT> 
     135inline void 
     136MChildFCPointerField<ObjectT, NamespaceI, AllocatorT>::resizeNoUnlink( 
     137    size_t newSize) 
     138{ 
     139    UInt32 oldSize = this->size(); 
     140     
     141    if(newSize < oldSize) 
     142    { 
     143        StorageIter vI = this->editRawStorage().begin() + newSize; 
     144        StorageIter vE = this->editRawStorage().end  (); 
     145         
     146        for(; vI != vE; ++vI) 
     147        { 
     148            decRefCount(*vI); 
     149        } 
     150    } 
     151     
     152    this->editRawStorage().resize(newSize); 
     153} 
     154 
    113155/*-------------------------------------------------------------------------*/ 
    114156/* MChildFCPointerField<class ObjectT,                                     */ 
     
    553595                     AllocatorT >::copyFromBin(BinaryDataHandler &pMem) 
    554596{ 
    555     UInt32 n; 
    556  
    557     pMem.getValue(n); 
    558     clear(); 
    559  
    560 #ifdef __hpux 
    561     StoredType tmpVal; 
    562     resize(n, tmpVal); 
    563 #else 
    564     resize(n); 
    565 #endif 
    566  
    567     if(n != 0) 
    568     { 
    569         MFieldTraits::copyFromBin(pMem, &(this->editRawStorage()[0]), n); 
     597    UInt32 newSize; 
     598     
     599    pMem.getValue(newSize); 
     600     
     601    if(newSize > 0) 
     602    { 
     603        this->resizeNoUnlink(newSize); 
     604         
     605        MFieldTraits::copyFromBin(pMem, &(this->editRawStorage()[0]), newSize); 
    570606         
    571607        StorageIter vI = this->editRawStorage().begin(); 
     
    575611        { 
    576612            incRefCount(*vI); 
    577             linkParent (*vI); 
    578613        } 
     614    } 
     615    else 
     616    { 
     617        this->clearNoUnlink(); 
    579618    } 
    580619} 
     
    9991038    UInt32 newSize = source. size(); 
    10001039 
     1040    // be careful to operate on raw storage, otherwise parent/child linking is 
     1041    // done, which is not necessary, since by assumption we sync to a correctly 
     1042    // linked aspect. 
     1043     
    10011044    if(newSize > 0) 
    10021045    { 
    1003         if(newSize < oldSize) 
    1004         { 
    1005             StorageIter oI = this->editRawStorage().begin() + newSize; 
    1006             StorageIter oE = this->editRawStorage().end  (); 
    1007              
    1008             for(; oI != oE; ++oI) 
    1009             { 
    1010                 decRefCount(*oI); 
    1011             } 
    1012         } 
    1013          
    1014         this->editRawStorage().resize(newSize); 
     1046        this->resizeNoUnlink(newSize); 
    10151047             
    10161048        StorageConstIter sI = source.getRawStorage ().begin(); 
     
    10341066    else 
    10351067    { 
    1036         clear(); 
     1068        this->clearNoUnlink(); 
    10371069    } 
    10381070}