Opencv 3.1 project on GR-PEACH board
Fork of gr-peach-opencv-project by
mbed-rtos/rtos/Mutex.h@170:54ff26da7eb6, 2017-07-04 (annotated)
- Committer:
- thedo
- Date:
- Tue Jul 04 06:23:13 2017 +0000
- Revision:
- 170:54ff26da7eb6
- Parent:
- 166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thedo | 166:3a9487d57a5c | 1 | /* mbed Microcontroller Library |
thedo | 166:3a9487d57a5c | 2 | * Copyright (c) 2006-2012 ARM Limited |
thedo | 166:3a9487d57a5c | 3 | * |
thedo | 166:3a9487d57a5c | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
thedo | 166:3a9487d57a5c | 5 | * of this software and associated documentation files (the "Software"), to deal |
thedo | 166:3a9487d57a5c | 6 | * in the Software without restriction, including without limitation the rights |
thedo | 166:3a9487d57a5c | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
thedo | 166:3a9487d57a5c | 8 | * copies of the Software, and to permit persons to whom the Software is |
thedo | 166:3a9487d57a5c | 9 | * furnished to do so, subject to the following conditions: |
thedo | 166:3a9487d57a5c | 10 | * |
thedo | 166:3a9487d57a5c | 11 | * The above copyright notice and this permission notice shall be included in |
thedo | 166:3a9487d57a5c | 12 | * all copies or substantial portions of the Software. |
thedo | 166:3a9487d57a5c | 13 | * |
thedo | 166:3a9487d57a5c | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
thedo | 166:3a9487d57a5c | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
thedo | 166:3a9487d57a5c | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
thedo | 166:3a9487d57a5c | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
thedo | 166:3a9487d57a5c | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
thedo | 166:3a9487d57a5c | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
thedo | 166:3a9487d57a5c | 20 | * SOFTWARE. |
thedo | 166:3a9487d57a5c | 21 | */ |
thedo | 166:3a9487d57a5c | 22 | #ifndef MUTEX_H |
thedo | 166:3a9487d57a5c | 23 | #define MUTEX_H |
thedo | 166:3a9487d57a5c | 24 | |
thedo | 166:3a9487d57a5c | 25 | #include <stdint.h> |
thedo | 166:3a9487d57a5c | 26 | #include "cmsis_os.h" |
thedo | 166:3a9487d57a5c | 27 | |
thedo | 166:3a9487d57a5c | 28 | namespace rtos { |
thedo | 166:3a9487d57a5c | 29 | /** \addtogroup rtos */ |
thedo | 166:3a9487d57a5c | 30 | /** @{*/ |
thedo | 166:3a9487d57a5c | 31 | |
thedo | 166:3a9487d57a5c | 32 | /** The Mutex class is used to synchronise the execution of threads. |
thedo | 166:3a9487d57a5c | 33 | This is for example used to protect access to a shared resource. |
thedo | 166:3a9487d57a5c | 34 | */ |
thedo | 166:3a9487d57a5c | 35 | class Mutex { |
thedo | 166:3a9487d57a5c | 36 | public: |
thedo | 166:3a9487d57a5c | 37 | /** Create and Initialize a Mutex object */ |
thedo | 166:3a9487d57a5c | 38 | Mutex(); |
thedo | 166:3a9487d57a5c | 39 | |
thedo | 166:3a9487d57a5c | 40 | /** Wait until a Mutex becomes available. |
thedo | 166:3a9487d57a5c | 41 | @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever) |
thedo | 166:3a9487d57a5c | 42 | @return status code that indicates the execution status of the function. |
thedo | 166:3a9487d57a5c | 43 | */ |
thedo | 166:3a9487d57a5c | 44 | osStatus lock(uint32_t millisec=osWaitForever); |
thedo | 166:3a9487d57a5c | 45 | |
thedo | 166:3a9487d57a5c | 46 | /** Try to lock the mutex, and return immediately |
thedo | 166:3a9487d57a5c | 47 | @return true if the mutex was acquired, false otherwise. |
thedo | 166:3a9487d57a5c | 48 | */ |
thedo | 166:3a9487d57a5c | 49 | bool trylock(); |
thedo | 166:3a9487d57a5c | 50 | |
thedo | 166:3a9487d57a5c | 51 | /** Unlock the mutex that has previously been locked by the same thread |
thedo | 166:3a9487d57a5c | 52 | @return status code that indicates the execution status of the function. |
thedo | 166:3a9487d57a5c | 53 | */ |
thedo | 166:3a9487d57a5c | 54 | osStatus unlock(); |
thedo | 166:3a9487d57a5c | 55 | |
thedo | 166:3a9487d57a5c | 56 | ~Mutex(); |
thedo | 166:3a9487d57a5c | 57 | |
thedo | 166:3a9487d57a5c | 58 | private: |
thedo | 166:3a9487d57a5c | 59 | osMutexId _osMutexId; |
thedo | 166:3a9487d57a5c | 60 | osMutexDef_t _osMutexDef; |
thedo | 166:3a9487d57a5c | 61 | #ifdef CMSIS_OS_RTX |
thedo | 166:3a9487d57a5c | 62 | #if defined(__MBED_CMSIS_RTOS_CA9) || defined(__MBED_CMSIS_RTOS_CM) |
thedo | 166:3a9487d57a5c | 63 | int32_t _mutex_data[4]; |
thedo | 166:3a9487d57a5c | 64 | #else |
thedo | 166:3a9487d57a5c | 65 | int32_t _mutex_data[3]; |
thedo | 166:3a9487d57a5c | 66 | #endif |
thedo | 166:3a9487d57a5c | 67 | #endif |
thedo | 166:3a9487d57a5c | 68 | }; |
thedo | 166:3a9487d57a5c | 69 | |
thedo | 166:3a9487d57a5c | 70 | } |
thedo | 166:3a9487d57a5c | 71 | #endif |
thedo | 166:3a9487d57a5c | 72 | |
thedo | 166:3a9487d57a5c | 73 | /** @}*/ |