summaryrefslogtreecommitdiff
path: root/cpp/test/IceUtil/thread/GCSharedTest.cpp
blob: 94c221dd67a3a041d371a31c3fa430ab97e3890f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 = false;
	Thread::_noDelete = true;
	//
	// If we have virtual bases, there will be only one instance of the IceUtil::Shared base class,
	// so GCShared::_noDelete will be true after the second assignment.
	//
	return GCShared::_noDelete;
    }
};

GCSharedTest::GCSharedTest() :
    TestBase(GCSharedTestName)
{
}

void
GCSharedTest::run()
{
    TestClass tc;
    test(tc.basesAreVirtual());
}