Main Page
+
Namespaces
Namespace List
+
Namespace Members
+
All
a
b
c
d
e
f
g
i
k
l
o
p
r
s
t
u
Functions
Variables
Typedefs
Enumerations
Enumerator
+
Classes
Class List
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
~
+
Functions
a
b
c
d
e
f
g
h
i
l
m
o
p
q
r
s
t
u
v
w
~
+
Variables
_
a
b
c
d
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Typedefs
Enumerations
Enumerator
Related Functions
+
Files
File List
+
File Members
+
All
d
g
i
l
m
s
v
+
Functions
m
v
Variables
+
Typedefs
v
Enumerations
+
Enumerator
v
Macros
include
VimbaCPP
Source
Condition.cpp
Go to the documentation of this file.
1
/*=============================================================================
2
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
3
4
Redistribution of this file, in original or modified form, without
5
prior written consent of Allied Vision Technologies is prohibited.
6
7
-------------------------------------------------------------------------------
8
9
File: Condition.cpp
10
11
Description: Implementation of a condition class.
12
Intended for use in the implementation of Vimba CPP API.
13
14
-------------------------------------------------------------------------------
15
16
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
17
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
18
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
24
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
=============================================================================*/
28
29
#include <
VimbaCPP/Source/Condition.h
>
30
31
namespace
AVT
{
32
namespace
VmbAPI {
33
34
Condition::Condition
()
35
: m_nWaiterNumber( 0 )
36
, m_nReleaseNumber( 0 )
37
, m_bLocked( true )
38
{
39
SP_SET
( m_Semaphore,
new
Semaphore
() );
40
}
41
42
void
Condition::Wait
(
const
BasicLockable
&rLockable )
43
{
44
Wait
( rLockable.
GetMutex
() );
45
}
46
47
void
Condition::Wait
(
const
MutexPtr &rMutex )
48
{
49
m_nWaiterNumber
++;
50
51
SP_ACCESS
( rMutex )->Unlock();
52
53
SP_ACCESS
( m_Semaphore )->Acquire();
54
55
SP_ACCESS
( rMutex) ->Lock();
56
57
if
(
m_nWaiterNumber
> 0 )
58
{
59
m_nWaiterNumber
--;
60
}
61
62
if
(
m_nReleaseNumber
> 0 )
63
{
64
m_nReleaseNumber
--;
65
}
66
67
if
(
m_nWaiterNumber
> 0
68
&&
m_nReleaseNumber
> 0 )
69
{
70
SP_ACCESS
( m_Semaphore )->Release();
71
m_bLocked
=
false
;
72
}
73
else
74
{
75
m_bLocked
=
true
;
76
}
77
78
if
(
m_nReleaseNumber
>
m_nWaiterNumber
)
79
{
80
m_nReleaseNumber
=
m_nWaiterNumber
;
81
}
82
}
83
84
void
Condition::Signal
(
bool
bSingle )
85
{
86
if
(
m_nWaiterNumber
>
m_nReleaseNumber
)
87
{
88
if
(
true
== bSingle )
89
{
90
m_nReleaseNumber
++;
91
}
92
else
93
{
94
m_nReleaseNumber
=
m_nWaiterNumber
;
95
}
96
97
if
(
true
==
m_bLocked
)
98
{
99
SP_ACCESS
( m_Semaphore )->Release();
100
m_bLocked
=
false
;
101
}
102
}
103
}
104
105
}}
// namespace AVT::VmbAPI
AVT::VmbAPI::BasicLockable
Definition:
BasicLockable.h:38
Condition.h
AVT::VmbAPI::Condition::Signal
void Signal(bool bSingle=false)
Definition:
Condition.cpp:84
SP_ACCESS
#define SP_ACCESS(sp)
Definition:
SharedPointerDefines.h:49
AVT::VmbAPI::Condition::Condition
Condition()
Definition:
Condition.cpp:34
AVT::VmbAPI::BasicLockable::GetMutex
MutexPtr & GetMutex()
Definition:
BasicLockable.cpp:48
SP_SET
#define SP_SET(sp, rawPtr)
Definition:
SharedPointerDefines.h:45
AVT
Definition:
AncillaryData.h:35
AVT::VmbAPI::Condition::Wait
void Wait(const BasicLockable &rLockable)
Definition:
Condition.cpp:42
AVT::VmbAPI::Condition::m_bLocked
bool m_bLocked
Definition:
Condition.h:45
AVT::VmbAPI::Condition::m_nWaiterNumber
unsigned long m_nWaiterNumber
Definition:
Condition.h:44
AVT::VmbAPI::Condition::m_nReleaseNumber
unsigned long m_nReleaseNumber
Definition:
Condition.h:43
AVT::VmbAPI::Semaphore
Definition:
Semaphore.h:43
avt_vimba_camera
Author(s): Allied Vision Technologies, Miquel Massot
autogenerated on Fri Jun 2 2023 02:21:10