RDK Documentation (Open Sourced RDK Components)
ConditionVariable.hpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /*****************************************************************************/
21 /*!
22 \file
23 \brief This file defines interface of ConditionVariable class.
24 
25 */
26 /*****************************************************************************/
27 
28 
29 
30 /**
31 * @defgroup hdmicec
32 * @{
33 * @defgroup osal
34 * @{
35 **/
36 
37 
38 #ifndef HDMI_CCEC_OSAL_CONDITION_VARIABLE_HPP_
39 #define HDMI_CCEC_OSAL_CONDITION_VARIABLE_HPP_
40 
41 #include "OSAL.hpp"
42 #include "Mutex.hpp"
43 #include "Condition.hpp"
44 
45 CCEC_OSAL_BEGIN_NAMESPACE
46 /***************************************************************************/
47 /*!
48 
49 ConditionVariable factors out the Object monitor methods (wait, notify and notifyAll)
50 into distinct objects to give the effect of having multiple wait-sets per object,
51 by combining them with the use of arbitrary Lock implementations.
52 
53 ConditionVariables provide a means for one thread to suspend execution (to "wait")
54 until notified by another thread that some state condition may now be true.
55 Because access to this shared state information occurs in different threads,
56 it must be protected, so a lock of some form is associated with the condition.
57 The key property that waiting for a condition provides is that it atomically
58 releases the associated lock and suspends the current thread.
59 
60 A ConditionVariable instance is intrinsically bound to a lock.
61 */
62 /**************************************************************************/
63 
64 
66 public:
67 /***************************************************************************/
68 /*!
69 \brief Constructor.
70 Creates a ConditionVariable object.
71 
72 */
73 /**************************************************************************/
74  ConditionVariable(void);
75 /***************************************************************************/
76 
77 /*!
78 \brief Destructor.
79 Destroys the ConditionVariable object.
80 
81 */
82 /**************************************************************************/
83 
84  ~ConditionVariable(void);
85 /***************************************************************************/
86 /*!
87 \brief sets the condition.
88 Sets the condition assosiated with the ConditionVariable object.
89 
90 */
91 /**************************************************************************/
92 
93  void set(void);
94 /***************************************************************************/
95 /*!
96 \brief resets the condition.
97 Resets the condition assosiated with the ConditionVariable object to default
98 (false).
99 
100 */
101 /**************************************************************************/
102 
103  void reset(void);
104 /***************************************************************************/
105 /*!
106 \brief Checks the status of the condition.
107 Returns the status of the condition associated. Could be true/false.
108 
109 \return - boolean value of the associated condition.
110 */
111 /**************************************************************************/
112  bool isSet(void);
113 /***************************************************************************/
114 /*!
115 \brief Wait until the conditional variable is signalled.
116 Causes the current thread to wait until it is signalled or interrupted.
117 Calling thread will wait undefinetly until some other thread signals the
118 ConditionVariable by calling notify/notifyAll.
119 */
120 /**************************************************************************/
121 
122  void wait(void);
123 /***************************************************************************/
124 /*!
125 \brief Wait until the conditional variable is signalled.
126 Causes the current thread to wait until it is signalled or interrupted .
127 Calling thread will wait undefinetly until some other thread signals the
128 ConditionVariable by calling notify/notifyAll.
129 */
130 /**************************************************************************/
131 
132  long wait(long timeout);
133  void notify(void);
134  void notifyAll(void);
135  void *getNativeHandle(void);
136 private:
137  Condition *cond;
138  Mutex *mutex;
139  void *nativeHandle;
140 
141  ConditionVariable(const ConditionVariable &); /* Not allowed */
142  ConditionVariable & operator = (const ConditionVariable &); /* Not allowed */
143 };
144 
145 CCEC_OSAL_END_NAMESPACE
146 #endif
147 
148 
149 /** @} */
150 /** @} */
CCEC_OSAL::Mutex
Definition: Mutex.hpp:53
CCEC_OSAL::Condition
Definition: Condition.hpp:52
Condition.hpp
This file defines interface of Condition class.
CCEC_OSAL::ConditionVariable
Definition: ConditionVariable.hpp:65
Mutex.hpp
This file defines interface of Mutex class.