Mistake on this page?
Report an issue in GitHub or email us
PlatformMutex.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2019 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef PLATFORM_MUTEX_H
18 #define PLATFORM_MUTEX_H
19 
20 #include "platform/NonCopyable.h"
21 
22 /** \addtogroup platform-public-api */
23 /** @{*/
24 
25 /** \defgroup platform_PlatformMutex PlatformMutex class
26  * @{
27  */
28 
29 /** The PlatformMutex class is used to synchronize the execution of threads.
30  *
31  * Mbed drivers use the PlatformMutex class instead of rtos::Mutex.
32  * This enables the use of drivers when the Mbed OS is compiled without the RTOS.
33  *
34  * @note
35  * - When the RTOS is present, the PlatformMutex becomes a typedef for rtos::Mutex.
36  * - When the RTOS is absent, all methods are defined as noop.
37  */
38 
39 #ifdef MBED_CONF_RTOS_API_PRESENT
40 
41 // rtos::Mutex is itself a dummy class if the RTOS API is present, but not the RTOS
42 #include "rtos/Mutex.h"
44 
45 #else
46 
47 class PlatformMutex: private mbed::NonCopyable<PlatformMutex> {
48 public:
49  /** Create a PlatformMutex object.
50  *
51  * @note When the RTOS is present, this is an alias for rtos::Mutex::Mutex().
52  */
54  {
55  }
56 
57  /** PlatformMutex destructor.
58  *
59  * @note When the RTOS is present, this is an alias for rtos::Mutex::~Mutex().
60  */
62  {
63  }
64 
65  /** Wait until a PlatformMutex becomes available.
66  *
67  * @note
68  * - When the RTOS is present, this is an alias for rtos::Mutex::lock().
69  * - When the RTOS is absent, this is a noop.
70  */
71  void lock()
72  {
73  }
74 
75  /** Unlock a PlatformMutex that the same thread has previously locked.
76  *
77  * @note
78  * - When the RTOS is present, this is an alias for rtos::Mutex::unlock().
79  * - When the RTOS is absent, this is a noop.
80  */
81  void unlock()
82  {
83  }
84 };
85 
86 #endif
87 
88 #endif
89 
90 /**@}*/
91 
92 /**@}*/
~PlatformMutex()
PlatformMutex destructor.
Definition: PlatformMutex.h:61
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:169
The PlatformMutex class is used to synchronize the execution of threads.
Definition: PlatformMutex.h:47
The Mutex class is used to synchronize the execution of threads.
Definition: Mutex.h:68
void unlock()
Unlock a PlatformMutex that the same thread has previously locked.
Definition: PlatformMutex.h:81
void lock()
Wait until a PlatformMutex becomes available.
Definition: PlatformMutex.h:71
PlatformMutex()
Create a PlatformMutex object.
Definition: PlatformMutex.h:53
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.