summaryrefslogtreecommitdiff
path: root/XMPCommon/Interfaces/ISharedMutex.h
blob: 7353ae37828ccf6831d69baea1453dc5ebc11360 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef ISharedMutex_h__
#define ISharedMutex_h__ 1

// =================================================================================================
// 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.
// =================================================================================================

#include "XMPCommon/XMPCommonFwdDeclarations_I.h"
#include "XMPCommon/Interfaces/BaseInterfaces/ISharedObject_I.h"
#include "XMPCommon/XMPCommonErrorCodes_I.h"

namespace XMP_COMPONENT_INT_NAMESPACE {

	//!
	//! Internal interface that represents a mutex object.
	//! \details Provides all the functions to lock/unlock the mutex.
	//!
	class XMP_PUBLIC ISharedMutex
		: public virtual ISharedObject
	{
	public:
		//!
		//! Locks the mutex in exclusive mode.
		//! \return a value of type eMutexErrorCode indicating the status of operation.
		//!
		virtual eMultiThreadingErrorCode APICALL Lock() __NOTHROW__ = 0;

		//!
		//! Tries to lock the mutex in exclusive mode.
		//! \return a value of type eMutexErrorCode indicating the status of operation.
		//!
		virtual eMultiThreadingErrorCode APICALL TryLock() __NOTHROW__ = 0;

		//!
		//! Unlocks the mutex in exclusive mode.
		//! \return a value of type eMutexErrorCode indicating the status of operation.
		//!
		virtual eMultiThreadingErrorCode APICALL Unlock() __NOTHROW__ = 0;

		//!
		//! Locks the mutex in non exclusive mode.
		//! \return a value of type eMutexErrorCode indicating the status of operation.
		//!
		virtual eMultiThreadingErrorCode APICALL LockShared() __NOTHROW__ = 0;

		//!
		//! Tries to lock the mutex in non exclusive mode.
		//! \return a value of type eMutexErrorCode indicating the status of operation.
		//!
		virtual eMultiThreadingErrorCode APICALL TryLockShared() __NOTHROW__ = 0;

		//!
		//! Unlocks the mutex in non exclusive mode.
		//! \return a value of type eMutexErrorCode indicating the status of operation.
		//!
		virtual eMultiThreadingErrorCode APICALL UnlockShared() __NOTHROW__ = 0;

		// factory methods
		//!
		//! Creates a mutex.
		//! \return a shared pointer to #ISharedMutex.
		//!
		static spISharedMutex CreateSharedMutex();

	protected:
		//!
		//! Destructor
		//! 
		virtual ~ISharedMutex() __NOTHROW__ {}

		//! \cond XMP_INTERNAL_DOCUMENTATION

	#ifdef FRIEND_CLASS_DECLARATION
		FRIEND_CLASS_DECLARATION();
	#endif
		REQ_FRIEND_CLASS_DECLARATION();
		//! \endcond

	};
}

#endif  // ISharedMutex_h__