diff options
author | Michi Henning <michi@zeroc.com> | 2005-01-14 01:56:58 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2005-01-14 01:56:58 +0000 |
commit | 3f9901c981dde5cbe245e8a0e3aee343af8f4cdd (patch) | |
tree | d535b0992db48fbc35e83d11f2a5b8a8ea5a6c5d /cpp/test/IceUtil/thread/GCSharedTest.cpp | |
parent | convert backslashes in ProgramName (diff) | |
download | ice-3f9901c981dde5cbe245e8a0e3aee343af8f4cdd.tar.bz2 ice-3f9901c981dde5cbe245e8a0e3aee343af8f4cdd.tar.xz ice-3f9901c981dde5cbe245e8a0e3aee343af8f4cdd.zip |
Changed inheritance of IceUtil::GCShared from IceUtil::Shared to virtual
inheritance, so we don't have two IceUtil::Shared instances in a class
that uses multiple inheritance and ends up deriving from
IceUtil::Shared more than once.
Added a test case to the thread tests for a class that inherits from both
GCShared and Thread to proved that there is indeed only one shared
instance of IceUtil::Shared in such a class.
Diffstat (limited to 'cpp/test/IceUtil/thread/GCSharedTest.cpp')
-rw-r--r-- | cpp/test/IceUtil/thread/GCSharedTest.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cpp/test/IceUtil/thread/GCSharedTest.cpp b/cpp/test/IceUtil/thread/GCSharedTest.cpp new file mode 100644 index 00000000000..73b7cc3c355 --- /dev/null +++ b/cpp/test/IceUtil/thread/GCSharedTest.cpp @@ -0,0 +1,50 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <IceUtil/IceUtil.h> + +#include <GCSharedTest.h> +#include <IceUtil/Thread.h> +#include <IceUtil/GCShared.h> +#include <TestCommon.h> + +using namespace std; +using namespace IceUtil; + +static const string GCSharedTestName("GCShared"); + +struct TestClass : public Thread, GCShared +{ + virtual void run() {} + virtual void __gcReachable(GCObjectMultiSet&) const {} + virtual void __gcClear() {} + + bool basesAreVirtual() + { + GCShared::_noDelete = true; + Thread::_noDelete = false; + // + // If we have virtual bases, there will be only one instance of the IceUtil::Shared base class, + // so GCShared::_noDelete will be false after the second assignment. + // + return !GCShared::_noDelete; + } +}; + +GCSharedTest::GCSharedTest() : + TestBase(GCSharedTestName) +{ +} + +void +GCSharedTest::run() +{ + TestClass tc; + test(tc.basesAreVirtual()); +} |