#include <type_traits>\r
#include <exception>\r
\r
-#include <tbb/spin_mutex.h>\r
+#include "../utility/assert.h"\r
\r
namespace caspar {\r
\r
class safe_ptr\r
{ \r
std::shared_ptr<T> impl_;\r
- tbb::spin_mutex mutex_;\r
template <typename> friend class safe_ptr;\r
public:\r
typedef T element_type;\r
return *this;\r
}\r
\r
- T& operator*() const { return *impl_.get();} // noexcept\r
+ T& operator*() const // noexcept\r
+ {\r
+ CASPAR_ASSERT(impl_);\r
+ return *impl_.get();\r
+ } \r
\r
- T* operator->() const { return impl_.get();} // noexcept\r
+ T* operator->() const // noexcept\r
+ {\r
+ CASPAR_ASSERT(impl_);\r
+ return impl_.get();\r
+ } \r
\r
- T* get() const { return impl_.get();} // noexcept\r
+ T* get() const // noexcept\r
+ {\r
+ CASPAR_ASSERT(impl_);\r
+ return impl_.get();\r
+ } \r
\r
bool unique() const { return impl_.unique();} // noexcept\r
\r
D* get_deleter(safe_ptr<U> const& ptr) { return impl_.get_deleter(); } // noexcept\r
};\r
\r
+template<class T, class U>\r
+bool operator==(const std::shared_ptr<T>& a, const safe_ptr<U>& b) // noexcept\r
+{\r
+ return a.get() == b.get();\r
+}\r
+\r
+template<class T, class U>\r
+bool operator==(const safe_ptr<T>& a, const std::shared_ptr<U>& b) // noexcept\r
+{\r
+ return a.get() == b.get();\r
+}\r
+\r
template<class T, class U>\r
bool operator==(const safe_ptr<T>& a, const safe_ptr<U>& b) // noexcept\r
{\r
return safe_ptr<T>(std::make_shared<T>(std::forward<P0>(p0), std::forward<P1>(p1), std::forward<P2>(p2), std::forward<P3>(p3), std::forward<P4>(p4)));\r
}\r
\r
+template<typename T, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5>\r
+safe_ptr<T> make_safe(P0&& p0, P1&& p1, P2&& p2, P3&& p3, P4&& p4, P5&& p5)\r
+{\r
+ return safe_ptr<T>(std::make_shared<T>(std::forward<P0>(p0), std::forward<P1>(p1), std::forward<P2>(p2), std::forward<P3>(p3), std::forward<P4>(p4), std::forward<P5>(p5)));\r
+}\r
+\r
}
\ No newline at end of file