Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
27 Base class for creating reference counted objects.
29 This provide basic reference counting and asynchronous cleanup
30 for derived classes. An object whose reference count reaches zero
33 class DReferenceCountedObject : public DBase
37 Constructs this object with an initial reference count of one.
39 DReferenceCountedObject();
42 Atomically increment this object's reference count.
43 A fault is raised if the count was initially <= 0.
45 @pre Calling thread must be in a critical section
46 @pre #iReferenceCount>0
51 Atomically increment this object's reference count if it
54 This is for use in situations where a reference counted object
55 is found by looking in a list, and the list may contain
56 objects which have had their reference counts decremented
57 to zero and are in the process of being cleaned up. A failure
58 to open a reference on these objects should be taken as an
59 indication that the object should be ignored, and treated as
60 though it were never found.
62 @return True if the count was incremented.
63 False if it wasn't: because it was initially <= 0.
65 @pre Calling thread must be in a critical section
70 Decrement this object's reference count and if it reaches zero,
73 @pre Calling thread must be in a critical section.
74 @pre No fast mutex can be held.
75 @pre No mutexes with order greater less than KMutexOrdKernelHeap can be held.
80 Decrement this object's reference count and if this reaches zero,
81 queue this object for asynchronous deletion.
83 @pre Calling thread must be in a critical section.
84 @pre No fast mutex can be held.
90 Destructor which asserts in debug builds that the object's reference count is zero.
92 virtual ~DReferenceCountedObject();
95 Return true if the preconditions for #Close are met.
96 This is for use by derived classes which overload the #Close method.
98 TBool CheckCloseIsSafe();
101 Return true if the preconditions for #AsyncClose are met.
102 This is for use by derived classes which overload the #AsyncClose method.
104 TBool CheckAsyncCloseIsSafe();
109 This object's reference count. Must always be >= 0.
111 TInt iReferenceCount;
115 FORCE_INLINE DReferenceCountedObject::DReferenceCountedObject()