(file) Return to instance.h CVS log (file) (dir) Up to [OMI] / omi / micxx

Diff for /omi/micxx/instance.h between version 1.2 and 1.3

version 1.2, 2015/04/20 18:10:13 version 1.3, 2015/04/20 18:19:53
Line 29 
Line 29 
 #include "linkage.h" #include "linkage.h"
 #include "atomic.h" #include "atomic.h"
 #include "memory.h" #include "memory.h"
 #include "string.h"  #include "micxx_string.h"
 #include "field.h" #include "field.h"
 #include "array.h" #include "array.h"
 #include "types.h" #include "types.h"
Line 50 
Line 50 
  
     Instance& operator=(const Instance& x);     Instance& operator=(const Instance& x);
  
       inline MI_Instance* GetInstance() const
       {
           return m_instance;
       }
   
     String GetNamespace() const;     String GetNamespace() const;
  
     void SetNamespace(const String& nameSpace);     void SetNamespace(const String& nameSpace);
Line 58 
Line 63 
  
     static const MI_ClassDecl* GetClassDecl();     static const MI_ClassDecl* GetClassDecl();
  
       // Sets whether to use copy-on-write behavior. This function is
       // experimental (as indicated by the leading double underscore).
       void __setCopyOnWrite(bool flag)
       {
           GetHeader(m_instance)->u.s.m_disableCopyOnWrite = flag ? 0 : 1;
       }
   
       // Gets the copy-on-write flag from the MI_Instance header.
       bool __getCopyOnWrite() const
       {
           return GetHeader(m_instance)->u.s.m_disableCopyOnWrite ? false : true;
       }
   
       // Forces a copy-on-write operation (if refrence count is not 1). After
       // calling this function, the instance will have a pointer to its own
       // copy of MI_Instance whose reference count is 1.
       void __forceCopyOnWrite()
       {
           Header* header = GetHeader(m_instance);
   
           // Avoid the copy on write if sharing has been enabled.
   
           if (AtomicGet(header->u.s.m_refCounter) != 1)
           {
               MI_Instance* current = m_instance;
               m_instance = Clone();
               AddRef(m_instance);
               Release(current);
           }
       }
   
 protected: protected:
  
     Instance(     Instance(
Line 81 
Line 117 
  
     void COW()     void COW()
     {     {
         if (AtomicGet(GetHeader(m_instance)->u.s.m_refCounter) != 1)          Header* header = GetHeader(m_instance);
   
           // Avoid the copy on write if sharing has been enabled.
   
           if (header->u.s.m_disableCopyOnWrite == 0 &&
               AtomicGet(header->u.s.m_refCounter) != 1)
         {         {
             MI_Instance* current = m_instance;             MI_Instance* current = m_instance;
             m_instance = Clone();             m_instance = Clone();
Line 107 
Line 148 
  
 private: private:
  
     // helper data - placed before MI_Instance strucutre      // helper data - placed before MI_Instance structure
     struct Header     struct Header
     {     {
         union         union
Line 115 
Line 156 
             struct _HeaderData             struct _HeaderData
             {             {
                 AtomicType              m_refCounter;                 AtomicType              m_refCounter;
                   unsigned int m_disableCopyOnWrite;
             }             }
             s;             s;
             char alignment[(sizeof(struct _HeaderData) + 7) & ~7];              char alignment[(sizeof(struct _HeaderData) + 15) & ~15];
         }         }
         u;         u;
     };     };


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

ViewCVS 0.9.2