ViSP
Main Page
Related Pages
Modules
Classes
Examples
All
Classes
Functions
Variables
Enumerations
Enumerator
Friends
Groups
Pages
vpMutex.h
1
/****************************************************************************
2
*
3
* $Id: vpMutex.h 4056 2013-01-05 13:04:42Z fspindle $
4
*
5
*
6
* This file is part of the ViSP software.
7
* Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
8
*
9
* This software is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU General Public License
11
* ("GPL") version 2 as published by the Free Software Foundation.
12
* See the file LICENSE.txt at the root directory of this source
13
* distribution for additional information about the GNU GPL.
14
*
15
* For using ViSP with software that can not be combined with the GNU
16
* GPL, please contact INRIA about acquiring a ViSP Professional
17
* Edition License.
18
*
19
* See http://www.irisa.fr/lagadic/visp/visp.html for more information.
20
*
21
* This software was developed at:
22
* INRIA Rennes - Bretagne Atlantique
23
* Campus Universitaire de Beaulieu
24
* 35042 Rennes Cedex
25
* France
26
* http://www.irisa.fr/lagadic
27
*
28
* If you have questions regarding the use of this file, please contact
29
* INRIA at visp@inria.fr
30
*
31
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
32
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
33
*
34
*
35
* Description:
36
* Mutex protection.
37
*
38
* Authors:
39
* Celine Teuliere
40
*
41
*****************************************************************************/
42
43
44
#ifndef __VP_MUTEX__
45
#define __VP_MUTEX__
46
47
#include <visp/vpConfig.h>
48
#include <visp/vpException.h>
49
#ifdef VISP_HAVE_PTHREAD
50
51
#include <pthread.h>
52
63
class
VISP_EXPORT
vpMutex
{
64
public
:
65
vpMutex
() {
66
pthread_mutex_init( &m_mutex, NULL );
67
}
68
void
lock
() {
69
pthread_mutex_lock( &m_mutex );
70
}
71
void
unlock
() {
72
pthread_mutex_unlock( &m_mutex );
73
}
74
85
class
VISP_EXPORT
vpScopedLock
86
{
87
private
:
88
vpMutex
& _mutex;
89
public
:
90
91
#ifndef DOXYGEN_SHOULD_SKIP_THIS
92
void
operator=(
const
vpScopedLock
&){
93
throw
vpException
(
vpException::functionNotImplementedError
,
"Not implemented!"
);
94
}
95
#endif
96
97
vpScopedLock
(
vpMutex
& mutex)
98
: _mutex(mutex)
99
{
100
_mutex.lock();
101
}
102
~vpScopedLock
()
103
{
104
_mutex.unlock();
105
}
106
};
107
private
:
108
pthread_mutex_t m_mutex;
109
};
110
111
#endif
112
113
#endif
src
tools
mutex
vpMutex.h
Generated on Fri Sep 27 2013 21:09:16 for ViSP by
1.8.4