HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
UT_Lockable.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: UT_Lockable.h (UT Library, C++)
7
*
8
* COMMENTS:
9
*
10
*/
11
12
#ifndef __UT_LOCKABLE_H_INCLUDED__
13
#define __UT_LOCKABLE_H_INCLUDED__
14
15
#include "
UT_API.h
"
16
#include "
UT_LockUtil.h
"
17
#include "
UT_NonCopyable.h
"
18
#include <
SYS/SYS_Types.h
>
19
20
/// UT_Lock interface adapter for C++11 mutexes
21
template
<
typename
MUTEX>
22
class
UT_Lockable
23
{
24
public
:
25
UT_Lockable
() { }
26
~UT_Lockable
() { }
27
28
UT_NON_COPYABLE
(
UT_Lockable
)
29
30
using
Scope
=
UT_UniqueLock
<
UT_Lockable
<MUTEX> >;
31
32
bool
tryLock
() {
return
myMutex.try_lock(); }
33
void
lock
() { myMutex.lock(); }
34
void
unlock
() { myMutex.unlock(); }
35
bool
safeLock
() {
lock
();
return
true
; }
36
37
bool
isLocked
()
38
{
39
if
(
tryLock
())
40
{
41
unlock
();
42
return
false
;
43
}
44
return
true
;
45
}
46
47
exint
getMemoryUsage
(
bool
inclusive)
const
48
{
49
return
(inclusive ?
sizeof
(*
this
) : 0);
50
}
51
52
protected
:
53
MUTEX&
mutex
() {
return
myMutex; }
54
55
private
:
56
MUTEX myMutex;
57
};
58
59
#endif // __UT_LOCKABLE_H_INCLUDED__
UT_Lockable::lock
void lock()
Definition:
UT_Lockable.h:33
UT_Lockable::getMemoryUsage
exint getMemoryUsage(bool inclusive) const
Definition:
UT_Lockable.h:47
UT_Lockable::tryLock
bool tryLock()
Definition:
UT_Lockable.h:32
UT_Lockable
UT_Lock interface adapter for C++11 mutexes.
Definition:
UT_Lockable.h:22
exint
int64 exint
Definition:
SYS_Types.h:125
UT_API.h
UT_Lockable::mutex
MUTEX & mutex()
Definition:
UT_Lockable.h:53
SYS_Types.h
UT_NON_COPYABLE
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
Definition:
UT_NonCopyable.h:31
UT_NonCopyable.h
UT_LockUtil.h
UT_Lockable::safeLock
bool safeLock()
Definition:
UT_Lockable.h:35
UT_UniqueLock
Definition:
UT_LockUtil.h:51
UT_Lockable::UT_Lockable
UT_Lockable()
Definition:
UT_Lockable.h:25
UT_Lockable::~UT_Lockable
~UT_Lockable()
Definition:
UT_Lockable.h:26
UT_Lockable::unlock
void unlock()
Definition:
UT_Lockable.h:34
UT_Lockable::isLocked
bool isLocked()
Definition:
UT_Lockable.h:37
UT
UT_Lockable.h
Generated on Sat Nov 23 2024 02:48:19 for HDK by
1.8.6