summaryrefslogtreecommitdiff
path: root/XMPCommon/source/SharedObjectImpl.cpp
blob: ffb78b900ea258c0478043745a121fa45d034f7b (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
// =================================================================================================
// Copyright Adobe
// Copyright 2014 Adobe
// All Rights Reserved
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
// of the Adobe license agreement accompanying it. 
// =================================================================================================

#define IMPLEMENTATION_HEADERS_CAN_BE_INCLUDED 1
	#include "XMPCommon/ImplHeaders/SharedObjectImpl.h"
#undef IMPLEMENTATION_HEADERS_CAN_BE_INCLUDED
#include <assert.h>

namespace XMP_COMPONENT_INT_NAMESPACE {

	void APICALL SharedObjectImpl::Acquire() const __NOTHROW__ {
		if ( mCountInternal != 0 ) {
			--mCountInternal;
		} else {
			++mRefCount;
		}
	}

	void APICALL SharedObjectImpl::Release() const __NOTHROW__ {
		if ( mRefCount.load( ) == 0 || --mRefCount == 0 ) {
			delete this;
		}
	}

	SharedObjectImpl::~SharedObjectImpl() __NOTHROW__ {
		assert( mRefCount == 0 );
	}

	void APICALL SharedObjectImpl::AcquireInternal() const __NOTHROW__ {
		++mCountInternal;
		++mRefCount;
	}

}