intrusive pointer test

This commit is contained in:
Peter Thorson
2012-01-06 09:35:02 -06:00
parent fa7cd63706
commit fe7a51bb32
2 changed files with 32 additions and 1 deletions

View File

@@ -256,7 +256,7 @@ protected:
*it,
boost::system::error_code()
)
);
);
}
m_read_waiting.empty();*/

View File

@@ -31,12 +31,43 @@
#include "../common.hpp"
#include "../utf8_validator/utf8_validator.hpp"
#include <boost/detail/atomic_count.hpp>
#include <algorithm>
#include <istream>
namespace websocketpp {
namespace message {
class intrusive_ptr_base {
public:
intrusive_ptr_base() : ref_count(0) {}
intrusive_ptr_base(intrusive_ptr_base const&) : ref_count(0) {}
intrusive_ptr_base& operator=(intrusive_ptr_base const& rhs) {
return *this;
}
friend void intrusive_ptr_add_ref(intrusive_ptr_base const* s) {
assert(s->ref_count >= 0);
assert(s != 0);
++s->ref_count;
}
friend void intrusive_ptr_release(intrusive_ptr_base const* s) {
assert(s->ref_count > 0);
assert(s != 0);
// TODO: thread safety
long count = --s->ref_count;
if (count == 1) {
// recycle if endpoint exists
} else if (count == 0) {
// delete
}
}
private:
mutable boost::detail::atomic_count ref_count;
};
class data {
public:
data();