Commit e1a21a76 authored by Dominik Charousset's avatar Dominik Charousset

got rid of legacy ref_counted_impl

parent 172a53f4
...@@ -63,7 +63,6 @@ cppa/detail/pseudo_tuple.hpp ...@@ -63,7 +63,6 @@ cppa/detail/pseudo_tuple.hpp
cppa/detail/ptype_to_type.hpp cppa/detail/ptype_to_type.hpp
cppa/detail/receive_loop_helper.hpp cppa/detail/receive_loop_helper.hpp
cppa/detail/recursive_queue_node.hpp cppa/detail/recursive_queue_node.hpp
cppa/detail/ref_counted_impl.hpp
cppa/detail/scheduled_actor_dummy.hpp cppa/detail/scheduled_actor_dummy.hpp
cppa/detail/serialize_tuple.hpp cppa/detail/serialize_tuple.hpp
cppa/detail/singleton_manager.hpp cppa/detail/singleton_manager.hpp
...@@ -280,3 +279,4 @@ cppa/network/default_peer_impl.hpp ...@@ -280,3 +279,4 @@ cppa/network/default_peer_impl.hpp
src/default_peer_impl.cpp src/default_peer_impl.cpp
cppa/network/default_peer_acceptor_impl.hpp cppa/network/default_peer_acceptor_impl.hpp
src/default_peer_acceptor_impl.cpp src/default_peer_acceptor_impl.cpp
src/ref_counted.cpp
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
#include "cppa/detail/boxed.hpp" #include "cppa/detail/boxed.hpp"
#include "cppa/detail/unboxed.hpp" #include "cppa/detail/unboxed.hpp"
#include "cppa/detail/value_guard.hpp" #include "cppa/detail/value_guard.hpp"
#include "cppa/detail/ref_counted_impl.hpp"
#include "cppa/detail/implicit_conversions.hpp" #include "cppa/detail/implicit_conversions.hpp"
namespace cppa { namespace detail { namespace cppa { namespace detail {
......
...@@ -34,11 +34,8 @@ ...@@ -34,11 +34,8 @@
#include <atomic> #include <atomic>
#include <cstddef> #include <cstddef>
#include "cppa/detail/ref_counted_impl.hpp"
namespace cppa { namespace cppa {
#ifdef CPPA_DOCUMENTATION
/** /**
* @brief A (thread safe) base class for reference counted objects * @brief A (thread safe) base class for reference counted objects
...@@ -51,31 +48,33 @@ class ref_counted { ...@@ -51,31 +48,33 @@ class ref_counted {
public: public:
inline ref_counted() : m_rc(0) { }
/** /**
* @brief Increases reference count by one. * @brief Increases reference count by one.
*/ */
void ref(); inline void ref() { ++m_rc; }
/** /**
* @brief Decreases reference cound by one. * @brief Decreases reference cound by one.
* @returns @p true if there are still references to this object * @returns @p true if there are still references to this object
* (reference count > 0); otherwise @p false. * (reference count > 0); otherwise @p false.
*/ */
bool deref(); inline bool deref() { return --m_rc > 0; }
/** /**
* @brief Queries if there is exactly one reference. * @brief Queries if there is exactly one reference.
* @returns @p true if reference count is one; otherwise @p false. * @returns @p true if reference count is one; otherwise @p false.
*/ */
bool unique(); inline bool unique() { return m_rc == 1; }
}; virtual ~ref_counted();
#else private:
typedef detail::ref_counted_impl< std::atomic<size_t> > ref_counted; std::atomic<size_t> m_rc;
#endif };
} // namespace cppa } // namespace cppa
......
...@@ -28,34 +28,11 @@ ...@@ -28,34 +28,11 @@
\******************************************************************************/ \******************************************************************************/
#ifndef CPPA_REF_COUNTED_IMPL_HPP
#define CPPA_REF_COUNTED_IMPL_HPP
namespace cppa { namespace detail { #include "cppa/ref_counted.hpp"
template<typename T> namespace cppa {
class ref_counted_impl {
T m_rc; ref_counted::~ref_counted() { }
ref_counted_impl(const ref_counted_impl&) = delete; } // namespace cppa
ref_counted_impl& operator=(const ref_counted_impl&) = delete;
public:
virtual ~ref_counted_impl() { }
inline ref_counted_impl() : m_rc(0) { }
inline void ref() { ++m_rc; }
inline bool deref() { return --m_rc > 0; }
inline bool unique() { return m_rc == 1; }
};
} } // namespace cppa::detail
#endif // CPPA_REF_COUNTED_IMPL_HPP
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
#include <cstddef> #include <cstddef>
#include "test.hpp" #include "test.hpp"
#include "cppa/ref_counted.hpp"
#include "cppa/intrusive_ptr.hpp" #include "cppa/intrusive_ptr.hpp"
#include "cppa/detail/ref_counted_impl.hpp"
using namespace cppa; using namespace cppa;
namespace { namespace {
...@@ -15,7 +14,7 @@ int class1_instances = 0; ...@@ -15,7 +14,7 @@ int class1_instances = 0;
} }
struct class0 : cppa::detail::ref_counted_impl<size_t> { struct class0 : ref_counted {
class0() { ++class0_instances; } class0() { ++class0_instances; }
virtual ~class0() { --class0_instances; } virtual ~class0() { --class0_instances; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment