µ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-evflags.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_EVFLAGS_H_
29 #define CMSIS_PLUS_RTOS_OS_EVFLAGS_H_
30 
31 // ----------------------------------------------------------------------------
32 
33 #if defined(__cplusplus)
34 
37 
38 // ----------------------------------------------------------------------------
39 
40 namespace os
41 {
42  namespace rtos
43  {
44 
45  // ========================================================================
46 
47 #pragma GCC diagnostic push
48 #pragma GCC diagnostic ignored "-Wpadded"
49 
56  {
57  public:
58 
59  // ======================================================================
60 
67  {
68  public:
69 
80  constexpr
81  attributes ();
82 
83  // The rule of five.
84  attributes (const attributes&) = default;
85  attributes (attributes&&) = default;
86  attributes&
87  operator= (const attributes&) = default;
88  attributes&
89  operator= (attributes&&) = default;
90 
94  ~attributes () = default;
95 
100  public:
101 
107  // Public members; no accessors and mutators required.
108  // Warning: must match the type & order of the C file header.
109  // Add more attributes here.
114  }; /* class attributes */
115 
120  static const attributes initializer;
121 
131  event_flags (const attributes& attr = initializer);
132 
138  event_flags (const char* name, const attributes& attr = initializer);
139 
144  // The rule of five.
145  event_flags (const event_flags&) = delete;
146  event_flags (event_flags&&) = delete;
147  event_flags&
148  operator= (const event_flags&) = delete;
149  event_flags&
150  operator= (event_flags&&) = delete;
151 
159  ~event_flags ();
160 
176  bool
177  operator== (const event_flags& rhs) const;
178 
183  public:
184 
204  result_t
205  wait (flags::mask_t mask, flags::mask_t* oflags,
207 
221  result_t
222  try_wait (flags::mask_t mask, flags::mask_t* oflags = nullptr,
224 
242  result_t
244  flags::mask_t* oflags = nullptr,
246 
256  result_t
257  raise (flags::mask_t mask, flags::mask_t* oflags = nullptr);
258 
267  result_t
268  clear (flags::mask_t mask, flags::mask_t* oflags = nullptr);
269 
279 
287  bool
288  waiting (void);
289 
294  protected:
295 
305 #if !defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
307  clock* clock_;
308 #endif
309 
310 #if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
311  friend class port::event_flags;
312  os_evflags_port_data_t port_;
313 #endif
314 
318  internal::event_flags event_flags_;
319 
328  };
329 
330 #pragma GCC diagnostic pop
331 
332  } /* namespace rtos */
333 } /* namespace os */
334 
335 // ===== Inline & template implementations ====================================
336 
337 namespace os
338 {
339  namespace rtos
340  {
341  constexpr
343  {
344  ;
345  }
346 
347  } /* namespace rtos */
348 } /* namespace os */
349 
350 // ----------------------------------------------------------------------------
351 
352 #endif /* __cplusplus */
353 
354 #endif /* CMSIS_PLUS_RTOS_OS_EVFLAGS_H_ */
static const attributes initializer
Default event flags initialiser.
Definition: os-evflags.h:120
Priority ordered list of threads.
Definition: os-lists.h:536
Ask for flags to be cleared after read.
Definition: os-decls.h:303
Base class for attributes.
Definition: os-decls.h:562
System namespace.
bool waiting(void)
Check if there are threads waiting.
Definition: os-evflags.cpp:644
constexpr attributes()
Construct an event flags attributes object instance.
Definition: os-evflags.h:342
Internal event flags implementation.
Definition: os-flags.h:51
result_t timed_wait(flags::mask_t mask, clock::duration_t timeout, flags::mask_t *oflags=nullptr, flags::mode_t mode=flags::mode::all|flags::mode::clear)
Timed wait for event flags.
Definition: os-evflags.cpp:421
const char * name(void) const
Get object name.
Definition: os-decls.h:760
Base class for named system objects.
Definition: os-decls.h:444
port::clock::duration_t duration_t
Type of variables holding clock durations.
Definition: os-clocks.h:72
Return when all flags are set.
Definition: os-decls.h:293
~attributes()=default
Destruct the event flags attributes object instance.
Event flags attributes.
Definition: os-evflags.h:66
Synchronised event flags.
Definition: os-evflags.h:55
event_flags(const attributes &attr=initializer)
Construct an event flags object instance.
Definition: os-evflags.cpp:125
result_t wait(flags::mask_t mask, flags::mask_t *oflags, flags::mode_t mode=flags::mode::all|flags::mode::clear)
Wait for event flags.
Definition: os-evflags.cpp:236
Generic clock.
Definition: os-clocks.h:54
~event_flags()
Destruct the event flags object instance.
Definition: os-evflags.cpp:196
uint32_t mask_t
Type of variables holding flags masks.
Definition: os-decls.h:265
result_t try_wait(flags::mask_t mask, flags::mask_t *oflags=nullptr, flags::mode_t mode=flags::mode::all|flags::mode::clear)
Try to wait for event flags.
Definition: os-evflags.cpp:339
result_t clear(flags::mask_t mask, flags::mask_t *oflags=nullptr)
Clear event flags.
Definition: os-evflags.cpp:575
uint32_t mode_t
Type of variables holding flags modes.
Definition: os-decls.h:275
uint32_t result_t
Type of values returned by RTOS functions.
Definition: os-decls.h:96
attributes & operator=(const attributes &)=default
bool operator==(const event_flags &rhs) const
Compare event flags.