FastUIDraw
inc
fastuidraw
util
mutex.hpp
Go to the documentation of this file.
1
/*!
2
* \file mutex.hpp
3
* \brief file mutex.hpp
4
*
5
* Copyright 2018 by Intel.
6
*
7
* Contact: kevin.rogovin@gmail.com
8
*
9
* This Source Code Form is subject to the
10
* terms of the Mozilla Public License, v. 2.0.
11
* If a copy of the MPL was not distributed with
12
* this file, You can obtain one at
13
* http://mozilla.org/MPL/2.0/.
14
*
15
* \author Kevin Rogovin <kevin.rogovin@gmail.com>
16
*
17
*/
18
19
#ifndef FASTUIDRAW_MUTEX_HPP
20
#define FASTUIDRAW_MUTEX_HPP
21
22
#include <
fastuidraw/util/util.hpp
>
23
24
namespace
fastuidraw
25
{
26
/*!\addtogroup Utility
27
* @{
28
*/
29
30
/*!
31
* Mutex implements a non-recursive mutex.
32
*/
33
class
Mutex
:
noncopyable
34
{
35
public
:
36
/*!
37
* Guard locks a mutex on ctor and unlock
38
* the mutex on dtor.
39
*/
40
class
Guard
:
noncopyable
41
{
42
public
:
43
/*!
44
* Ctor.
45
* \param m mutex is locked on ctor and unlocked on dtor.
46
*/
47
explicit
48
Guard
(
Mutex
&m):
49
m_mutex(m)
50
{
51
m_mutex.
lock
();
52
}
53
54
~
Guard
()
55
{
56
m_mutex.
unlock
();
57
}
58
59
private
:
60
Mutex
&m_mutex;
61
};
62
63
/*!
64
* Ctor.
65
*/
66
Mutex
(
void
);
67
68
~
Mutex
(
void
);
69
70
/*!
71
* Aquire the lock of the mutex;
72
* only return once the lock is aquired.
73
*/
74
void
75
lock
(
void
);
76
77
/*!
78
* Release the lock of the mutex.
79
*/
80
void
81
unlock
(
void
);
82
83
/*!
84
* Try to aquire the lock of the mutex;
85
* if the mutex is already locked return
86
* false; otherwise return true.
87
*/
88
bool
89
try_lock
(
void
);
90
91
private
:
92
void
*m_d;
93
};
94
95
/*! @} */
96
}
97
98
#endif
fastuidraw::Mutex::try_lock
bool try_lock(void)
fastuidraw
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition:
colorstop.hpp:28
fastuidraw::Mutex::lock
void lock(void)
fastuidraw::Mutex::Guard
Definition:
mutex.hpp:40
fastuidraw::Mutex::Guard::Guard
Guard(Mutex &m)
Definition:
mutex.hpp:48
util.hpp
file util.hpp
fastuidraw::Mutex::unlock
void unlock(void)
fastuidraw::Mutex
Definition:
mutex.hpp:33
fastuidraw::noncopyable
Class for which copy ctor and assignment operator are private functions.
Definition:
util.hpp:505
fastuidraw::Mutex::Mutex
Mutex(void)
Generated by
1.8.13