(file) Return to Sharable.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Sharable.h between version 1.10 and 1.11

version 1.10, 2002/11/05 22:14:02 version 1.11, 2002/11/06 18:50:17
Line 33 
Line 33 
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/Linkage.h> #include <Pegasus/Common/Linkage.h>
 #include <Pegasus/Common/IPC.h> #include <Pegasus/Common/IPC.h>
   #include <assert.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 52 
Line 53 
     Sharable() : _ref(1) { }     Sharable() : _ref(1) { }
  
     virtual ~Sharable();     virtual ~Sharable();
     Uint32 getRef() const { return _ref; }      Uint32 getRef() const { return _ref.value(); }
     //    Uint32 getRef() const { return _ref.value(); }  
  
     friend void Inc(const Sharable* sharable);     friend void Inc(const Sharable* sharable);
  
     friend void Dec(const Sharable* sharable);     friend void Dec(const Sharable* sharable);
  
 private: private:
     Uint32 _ref;          AtomicInt _ref;
     //    AtomicInt _ref;  
 }; };
  
 inline void Inc(const Sharable* x) inline void Inc(const Sharable* x)
  
 { {
     if (x)     if (x)
       {
         // A sharable object should never be incremented from zero.
         // If so, there is a double delete being cause by impropoer use
         // of sharable assignment or copy constructors somewhere
         // << Wed Nov  6 12:46:52 2002 mdd >>
         assert(((Sharable*)x)->_ref.value());
         ((Sharable*)x)->_ref++;         ((Sharable*)x)->_ref++;
 } }
  
   }
   
   
 inline void Dec(const Sharable* x) inline void Dec(const Sharable* x)
 { {
     if (x && --((Sharable*)x)->_ref == 0)    if (x && ((Sharable*)x)->_ref.DecAndTestIfZero())
         delete (Sharable*)x;         delete (Sharable*)x;
   
     //    if (x && ((Sharable*)x)->_ref.DecAndTestIfZero())  
     //  delete (Sharable*)x;  
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2