ROSE  0.11.96.11
SharedObject.h
1 // WARNING: Changes to this file must be contributed back to Sawyer or else they will
2 // be clobbered by the next update from Sawyer. The Sawyer repository is at
3 // https://github.com/matzke1/sawyer.
4 
5 
6 
7 
8 #ifndef Sawyer_SharedObject_H
9 #define Sawyer_SharedObject_H
10 
11 #include <Sawyer/Sawyer.h>
12 #include <Sawyer/Synchronization.h>
13 
14 namespace Sawyer {
15 
64 class SAWYER_EXPORT SharedObject {
65  template<class U> friend class SharedPointer;
66  mutable SAWYER_THREAD_TRAITS::Mutex mutex_;
67  mutable size_t nrefs_;
68 public:
70  SharedObject(): nrefs_(0) {}
71 
76  SharedObject(const SharedObject&): nrefs_(0) {}
77 
79  virtual ~SharedObject() {
80  ASSERT_require(nrefs_==0);
81  }
82 
87  return *this;
88  }
89 };
90 
91 } // namespace
92 
93 #endif
Sawyer::SharedObject::~SharedObject
virtual ~SharedObject()
Virtual destructor.
Definition: SharedObject.h:79
Sawyer::SharedObject::SharedObject
SharedObject()
Default constructor.
Definition: SharedObject.h:70
Sawyer::SharedPointer
Reference-counting intrusive smart pointer.
Definition: SharedPointer.h:68
Sawyer
Name space for the entire library.
Definition: Access.h:13
Sawyer::SharedObject::operator=
SharedObject & operator=(const SharedObject &)
Assignment.
Definition: SharedObject.h:86
Sawyer::SharedObject
Base class for reference counted objects.
Definition: SharedObject.h:64
Sawyer::SharedObject::SharedObject
SharedObject(const SharedObject &)
Copy constructor.
Definition: SharedObject.h:76