summaryrefslogtreecommitdiff
path: root/XMPCommon/source/ThreadSafeImpl.cpp
blob: f760f6380925a2a7d1a5da1d340fb5b0cb752715 (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
51
52
53
// =================================================================================================
// Copyright Adobe
// Copyright 2015 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. If you have received this file from a source other 
// than Adobe, then your use, modification, or distribution of it requires the prior written permission
// of Adobe.
// =================================================================================================

#define IMPLEMENTATION_HEADERS_CAN_BE_INCLUDED 1
	#include "XMPCommon/ImplHeaders/ThreadSafeImpl.h"
#undef IMPLEMENTATION_HEADERS_CAN_BE_INCLUDED

#include "XMPCommon/Interfaces/IError_I.h"
#include "XMPCommon/Interfaces/ISharedMutex.h"

namespace XMP_COMPONENT_INT_NAMESPACE {

	// All virtual functions
	
	// All static functions of _I class.

	void APICALL ThreadSafeImpl::ShareMutex( const spISharedMutex & mutex ) {
		mSharedMutex = mutex;
	}

	void APICALL ThreadSafeImpl::UnShareMutex() {
		if ( mSharedMutex ) {
			mSharedMutex = ISharedMutex::CreateSharedMutex();
		} else {
			mSharedMutex.reset();
		}
	}

	void APICALL ThreadSafeImpl::EnableThreadSafety() const __NOTHROW__ {
		if ( !mSharedMutex ) {
			mSharedMutex = ISharedMutex::CreateSharedMutex();
		}
	}

	void APICALL ThreadSafeImpl::DisableThreadSafety() const __NOTHROW__ {
		if ( mSharedMutex )
			mSharedMutex.reset();
	}

	bool APICALL ThreadSafeImpl::IsThreadSafe() const {
		if ( mSharedMutex ) return true;
		return false;
	}

}