diff options
author | Thorsten Behrens <thb@openoffice.org> | 2006-03-23 14:25:00 +0000 |
---|---|---|
committer | Thorsten Behrens <thb@openoffice.org> | 2006-03-23 14:25:00 +0000 |
commit | 93b0a13d2de166c48ba7e182c306df1806b05eec (patch) | |
tree | c4c81e25b2b84af58b28cd866a5f444903df603f /o3tl/qa | |
parent | 6d036b06fa079f04cd16cbb4b243fa7b5be3ebc3 (diff) |
#i63310# Made cow_wrapper refcounting behaviour configurable via policy class (otherwise, code like basegfx, which previously hadn't used thread-safe refcounting, would now been hit by the performance penalty); added compile-test for ThreadSafeRefCountingPolicy to unit tests; removed cruft from unit tests
Diffstat (limited to 'o3tl/qa')
-rw-r--r-- | o3tl/qa/cow_wrapper_clients.cxx | 71 | ||||
-rw-r--r-- | o3tl/qa/cow_wrapper_clients.hxx | 33 |
2 files changed, 100 insertions, 4 deletions
diff --git a/o3tl/qa/cow_wrapper_clients.cxx b/o3tl/qa/cow_wrapper_clients.cxx index c389b7d8dd79..37d71061b258 100644 --- a/o3tl/qa/cow_wrapper_clients.cxx +++ b/o3tl/qa/cow_wrapper_clients.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cow_wrapper_clients.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: thb $ $Date: 2006-02-01 10:55:36 $ + * last change: $Author: thb $ $Date: 2006-03-23 15:25:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -144,4 +144,71 @@ bool cow_wrapper_client2::operator<( const cow_wrapper_client2& rRHS ) const return maImpl < rRHS.maImpl; } +// --------------------------------------------------------------------------- + +cow_wrapper_client3::cow_wrapper_client3() : maImpl() +{ +} + +cow_wrapper_client3::cow_wrapper_client3( int nVal ) : + maImpl( cow_wrapper_client2_impl(nVal) ) +{ +} + +cow_wrapper_client3::~cow_wrapper_client3() +{ +} + +cow_wrapper_client3::cow_wrapper_client3( const cow_wrapper_client3& rSrc ) : + maImpl(rSrc.maImpl) +{ +} + +cow_wrapper_client3& cow_wrapper_client3::operator=( const cow_wrapper_client3& rSrc ) +{ + maImpl = rSrc.maImpl; + + return *this; +} + +void cow_wrapper_client3::modify( int nVal ) +{ + maImpl->setValue( nVal ); +} + +int cow_wrapper_client3::queryUnmodified() const +{ + return maImpl->getValue(); +} + +void cow_wrapper_client3::makeUnique() +{ + maImpl.make_unique(); +} +bool cow_wrapper_client3::is_unique() const +{ + return maImpl.is_unique(); +} +oslInterlockedCount cow_wrapper_client3::use_count() const +{ + return maImpl.use_count(); +} +void cow_wrapper_client3::swap( cow_wrapper_client3& r ) +{ + o3tl::swap(maImpl, r.maImpl); +} + +bool cow_wrapper_client3::operator==( const cow_wrapper_client3& rRHS ) const +{ + return maImpl == rRHS.maImpl; +} +bool cow_wrapper_client3::operator!=( const cow_wrapper_client3& rRHS ) const +{ + return maImpl != rRHS.maImpl; +} +bool cow_wrapper_client3::operator<( const cow_wrapper_client3& rRHS ) const +{ + return maImpl < rRHS.maImpl; +} + } // namespace o3tltests diff --git a/o3tl/qa/cow_wrapper_clients.hxx b/o3tl/qa/cow_wrapper_clients.hxx index 49a9cb5023d5..013414d477ec 100644 --- a/o3tl/qa/cow_wrapper_clients.hxx +++ b/o3tl/qa/cow_wrapper_clients.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cow_wrapper_clients.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: thb $ $Date: 2006-01-25 16:17:38 $ + * last change: $Author: thb $ $Date: 2006-03-23 15:25:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -128,6 +128,35 @@ private: o3tl::cow_wrapper< cow_wrapper_client2_impl > maImpl; }; +/** test MT-safe cow_wrapper - basically the same as + cow_wrapper_client2, only with different refcounting policy + */ +class cow_wrapper_client3 +{ +public: + cow_wrapper_client3(); + explicit cow_wrapper_client3( int nVal ); + ~cow_wrapper_client3(); + + cow_wrapper_client3( const cow_wrapper_client3& ); + cow_wrapper_client3& operator=( const cow_wrapper_client3& ); + + void modify( int nVal ); + int queryUnmodified() const; + + void makeUnique(); + bool is_unique() const; + oslInterlockedCount use_count() const; + void swap( cow_wrapper_client3& r ); + + bool operator==( const cow_wrapper_client3& rRHS ) const; + bool operator!=( const cow_wrapper_client3& rRHS ) const; + bool operator<( const cow_wrapper_client3& rRHS ) const; + +private: + o3tl::cow_wrapper< cow_wrapper_client2_impl, o3tl::ThreadSafeRefCountingPolicy > maImpl; +}; + } // namespace o3tltests #endif /* INCLUDED_COW_WRAPPER_CLIENTS_HXX */ |