ROSE 0.11.145.147
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://gitlab.com/charger7534/sawyer.git.
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
14namespace Sawyer {
15
64class SAWYER_EXPORT SharedObject {
65 template<class U> friend class SharedPointer;
66 mutable SAWYER_THREAD_TRAITS::Mutex mutex_;
67 mutable size_t nrefs_;
68public:
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
Base class for reference counted objects.
SharedObject(const SharedObject &)
Copy constructor.
SharedObject & operator=(const SharedObject &)
Assignment.
virtual ~SharedObject()
Virtual destructor.
SharedObject()
Default constructor.
Reference-counting intrusive smart pointer.
Sawyer support library.