µOS++ IIIe Reference  v6.3.15
“Perfekt ist nicht gut genug”
The third edition of µOS++, a POSIX inspired open source system, written in C++.
os-condvar.h
Go to the documentation of this file.
1 /*
2  * This file is part of the µOS++ distribution.
3  * (https://github.com/micro-os-plus)
4  * Copyright (c) 2016 Liviu Ionescu.
5  *
6  * Permission is hereby granted, free of charge, to any person
7  * obtaining a copy of this software and associated documentation
8  * files (the "Software"), to deal in the Software without
9  * restriction, including without limitation the rights to use,
10  * copy, modify, merge, publish, distribute, sublicense, and/or
11  * sell copies of the Software, and to permit persons to whom
12  * the Software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  */
27 
28 #ifndef CMSIS_PLUS_RTOS_OS_CONDVAR_H_
29 #define CMSIS_PLUS_RTOS_OS_CONDVAR_H_
30 
31 // ----------------------------------------------------------------------------
32 
33 #if defined(__cplusplus)
34 
36 
37 // ----------------------------------------------------------------------------
38 
39 namespace os
40 {
41  namespace rtos
42  {
43 
44  // ========================================================================
45 
52  {
53  public:
54 
55  // ======================================================================
56 
63  {
64  public:
65 
76  constexpr
77  attributes ();
78 
79  // The rule of five.
80  attributes (const attributes&) = default;
81  attributes (attributes&&) = default;
82  attributes&
83  operator= (const attributes&) = default;
84  attributes&
85  operator= (attributes&&) = default;
86 
90  ~attributes () = default;
91 
96  public:
97 
103  // Public members; no accessors and mutators required.
104  // Warning: must match the type & order of the C file header.
105  // Add more attributes here.
110  }; /* class attributes */
111 
116  static const attributes initializer;
117 
118  // ======================================================================
119 
137  condition_variable (const attributes& attr = initializer);
138 
152  condition_variable (const char* name,
153  const attributes& attr = initializer);
154 
159  // The rule of five.
160  condition_variable (const condition_variable&) = delete;
163  operator= (const condition_variable&) = delete;
165  operator= (condition_variable&&) = delete;
166 
175 
191  bool
192  operator== (const condition_variable& rhs) const;
193 
198  public:
199 
214  result_t
215  signal (void);
216 
226  result_t
227  broadcast (void);
228 
246  result_t
247  wait (mutex& mutex);
248 
249  // Neither POSIX nor ISO define a try_wait(), it makes no sense.
250 
270  result_t
272 
277  protected:
278 
288 #if !defined(OS_USE_RTOS_PORT_CONDITION_VARIABLE)
290  // clock& clock_;
291 #endif
292 
297  // Add more internal data.
302  };
303 
304  } /* namespace rtos */
305 } /* namespace os */
306 
307 // ===== Inline & template implementations ====================================
308 
309 namespace os
310 {
311  namespace rtos
312  {
313  constexpr
315  {
316  ;
317  }
318 
319  // ========================================================================
320 
325  inline bool
327  {
328  return this == &rhs;
329  }
330 
331  } /* namespace rtos */
332 } /* namespace os */
333 
334 // ----------------------------------------------------------------------------
335 
336 #endif /* __cplusplus */
337 
338 #endif /* CMSIS_PLUS_RTOS_OS_CONDVAR_H_ */
static const attributes initializer
Default condition variable initialiser.
Definition: os-condvar.h:116
Priority ordered list of threads.
Definition: os-lists.h:536
POSIX compliant mutex.
Definition: os-mutex.h:53
~attributes()=default
Destruct the condition variable attributes object instance.
Base class for attributes.
Definition: os-decls.h:562
System namespace.
constexpr attributes()
Construct a condition variable attributes object instance.
Definition: os-condvar.h:314
const char * name(void) const
Get object name.
Definition: os-decls.h:760
result_t wait(mutex &mutex)
Wait for a condition variable to be notified.
Definition: os-condvar.cpp:506
Base class for named system objects.
Definition: os-decls.h:444
attributes & operator=(const attributes &)=default
port::clock::duration_t duration_t
Type of variables holding clock durations.
Definition: os-clocks.h:72
POSIX compliant condition variable.
Definition: os-condvar.h:51
result_t timed_wait(mutex &mutex, clock::duration_t timeout)
Timed wait for a condition variable to be notified.
Definition: os-condvar.cpp:651
result_t signal(void)
Notify one thread waiting for a condition variable.
Definition: os-condvar.cpp:336
result_t broadcast(void)
Notify all threads waiting for a condition variable.
Definition: os-condvar.cpp:406
condition_variable(const attributes &attr=initializer)
Construct a condition variable object instance.
Definition: os-condvar.cpp:226
Condition variable attributes.
Definition: os-condvar.h:62
~condition_variable()
Destruct the condition variable object instance.
Definition: os-condvar.cpp:291
uint32_t result_t
Type of values returned by RTOS functions.
Definition: os-decls.h:96
bool operator==(const condition_variable &rhs) const
Compare condition variables.
Definition: os-condvar.h:326