MoJo / ER2_Robot_gnuarmeclipse_lpc1768-V2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PlatformMutex.h Source File

PlatformMutex.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef PLATFORM_MUTEX_H
00017 #define PLATFORM_MUTEX_H
00018 
00019 #include "platform/NonCopyable.h"
00020 
00021 /** \addtogroup platform
00022  * @{
00023  */
00024 
00025 /** \defgroup platform_PlatformMutex PlatformMutex class
00026  * @{
00027  */
00028 
00029 /** The PlatformMutex class is used to synchronize the execution of threads.
00030  *
00031  * Mbed drivers use the PlatformMutex class instead of rtos::Mutex.
00032  * This enables the use of drivers when the Mbed OS is compiled without the RTOS.
00033  *
00034  * @note
00035  * - When the RTOS is present, the PlatformMutex becomes a typedef for rtos::Mutex.
00036  * - When the RTOS is absent, all methods are defined as noop.
00037  */
00038 
00039 #ifdef MBED_CONF_RTOS_PRESENT
00040 
00041 #include "rtos/Mutex.h"
00042 typedef rtos::Mutex PlatformMutex;
00043 
00044 #else
00045 
00046 class PlatformMutex: private mbed::NonCopyable<PlatformMutex> {
00047 public:
00048     /** Create a PlatformMutex object.
00049      *
00050      * @note When the RTOS is present, this is an alias for rtos::Mutex::Mutex().
00051      */
00052     PlatformMutex()
00053     {
00054     }
00055 
00056     /** PlatformMutex destructor.
00057      *
00058      * @note When the RTOS is present, this is an alias for rtos::Mutex::~Mutex().
00059      */
00060     ~PlatformMutex()
00061     {
00062     }
00063 
00064     /** Wait until a PlatformMutex becomes available.
00065      *
00066      * @note
00067      * - When the RTOS is present, this is an alias for rtos::Mutex::lock().
00068      * - When the RTOS is absent, this is a noop.
00069      */
00070     void lock()
00071     {
00072     }
00073 
00074     /** Unlock a PlatformMutex that the same thread has previously locked.
00075      *
00076      * @note
00077      * - When the RTOS is present, this is an alias for rtos::Mutex::unlock().
00078      * - When the RTOS is absent, this is a noop.
00079      */
00080     void unlock()
00081     {
00082     }
00083 };
00084 
00085 #endif
00086 
00087 #endif
00088 
00089 /**@}*/
00090 
00091 /**@}*/