|
1 |
| - |
2 |
| -/** \addtogroup platform */ |
3 |
| -/** @{*/ |
4 |
| -/** |
5 |
| - * \defgroup platform_PlatformMutex PlatformMutex class |
6 |
| - * @{ |
7 |
| - */ |
8 | 1 | /* mbed Microcontroller Library
|
9 | 2 | * Copyright (c) 2006-2013 ARM Limited
|
10 | 3 | *
|
|
25 | 18 |
|
26 | 19 | #include "platform/NonCopyable.h"
|
27 | 20 |
|
| 21 | +/** \addtogroup platform |
| 22 | + * @{ |
| 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 | + * The PlatformMutex class is used by Mbed OS drivers 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 | + |
28 | 39 | #ifdef MBED_CONF_RTOS_PRESENT
|
| 40 | + |
29 | 41 | #include "rtos/Mutex.h"
|
30 | 42 | typedef rtos::Mutex PlatformMutex;
|
| 43 | + |
31 | 44 | #else
|
32 |
| -/** A stub mutex for when an RTOS is not present |
33 |
| -*/ |
34 |
| -class PlatformMutex : private mbed::NonCopyable<PlatformMutex> { |
| 45 | + |
| 46 | +class PlatformMutex: private mbed::NonCopyable<PlatformMutex> { |
35 | 47 | public:
|
| 48 | + /** Create a PlatformMutex object. |
| 49 | + * |
| 50 | + * @note When the RTOS is present, this is an alias for rtos::Mutex::Mutex(). |
| 51 | + */ |
36 | 52 | PlatformMutex()
|
37 | 53 | {
|
38 |
| - // Stub |
39 |
| - |
40 | 54 | }
|
| 55 | + |
| 56 | + /** PlatformMutex destructor. |
| 57 | + * |
| 58 | + * @note When the RTOS is present, this is an alias for rtos::Mutex::~Mutex(). |
| 59 | + */ |
41 | 60 | ~PlatformMutex()
|
42 | 61 | {
|
43 |
| - // Stub |
44 | 62 | }
|
45 | 63 |
|
| 64 | + /** Wait until a PlatformMutex becomes available. |
| 65 | + * |
| 66 | + * @note |
| 67 | + * - When the RTOS is present, this is an alias for rtos::Mutex::lock(). |
| 68 | + * - When the RTOS is absent, this is a noop. |
| 69 | + */ |
46 | 70 | void lock()
|
47 | 71 | {
|
48 |
| - // Do nothing |
49 | 72 | }
|
50 | 73 |
|
| 74 | + /** Unlock a PlatformMutex that has previously been locked by the same thread. |
| 75 | + * |
| 76 | + * @note |
| 77 | + * - When the RTOS is present, this is an alias for rtos::Mutex::unlock(). |
| 78 | + * - When the RTOS is absent, this is a noop. |
| 79 | + */ |
51 | 80 | void unlock()
|
52 | 81 | {
|
53 |
| - // Do nothing |
54 | 82 | }
|
55 | 83 | };
|
56 | 84 |
|
|
0 commit comments