From 80686d4e567bae579ea39e009826a2de92cd4ace Mon Sep 17 00:00:00 2001 From: redpony Date: Wed, 11 Aug 2010 02:37:10 +0000 Subject: major refactor, break bad circular deps git-svn-id: https://ws10smt.googlecode.com/svn/trunk@509 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/intrusive_refcount.hpp | 84 ------------------------------------------ 1 file changed, 84 deletions(-) delete mode 100755 decoder/intrusive_refcount.hpp (limited to 'decoder/intrusive_refcount.hpp') diff --git a/decoder/intrusive_refcount.hpp b/decoder/intrusive_refcount.hpp deleted file mode 100755 index 4a4b0187..00000000 --- a/decoder/intrusive_refcount.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef GRAEHL__SHARED__INTRUSIVE_REFCOUNT_HPP -#define GRAEHL__SHARED__INTRUSIVE_REFCOUNT_HPP - -#include -#include -#include -#include - -/** usage: - struct mine : public boost::instrusive_refcount {}; - - boost::intrusive_ptr p(new mine()); -*/ - -namespace boost { -// note: the free functions need to be in boost namespace, OR namespace of involved type. this is the only way to do it. - -template -class intrusive_refcount; - -template -class atomic_intrusive_refcount; - -template -void intrusive_ptr_add_ref(intrusive_refcount* ptr) -{ - ++(ptr->refs); -} - -template -void intrusive_ptr_release(intrusive_refcount* ptr) -{ - if (!--(ptr->refs)) delete static_cast(ptr); -} - - -//WARNING: only 2^32 (unsigned) refs allowed. hope that's ok :) -template -class intrusive_refcount : boost::noncopyable -{ - protected: -// typedef intrusive_refcount pointed_type; - friend void intrusive_ptr_add_ref(intrusive_refcount* ptr); - friend void intrusive_ptr_release(intrusive_refcount* ptr); -// friend class intrusive_ptr; - - intrusive_refcount(): refs(0) {} - ~intrusive_refcount() { assert(refs==0); } - -private: - unsigned refs; -}; - - -template -void intrusive_ptr_add_ref(atomic_intrusive_refcount* ptr) -{ - ++(ptr->refs); -} - -template -void intrusive_ptr_release(atomic_intrusive_refcount* ptr) -{ - if(!--(ptr->refs)) delete static_cast(ptr); -} - -template -class atomic_intrusive_refcount : boost::noncopyable -{ - protected: - friend void intrusive_ptr_add_ref(atomic_intrusive_refcount* ptr); - friend void intrusive_ptr_release(atomic_intrusive_refcount* ptr); - - atomic_intrusive_refcount(): refs(0) {} - ~atomic_intrusive_refcount() { assert(refs==0); } - -private: - boost::detail::atomic_count refs; -}; - -} - - -#endif -- cgit v1.2.3