Ethernetwebsoc
Dependencies: C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip
mbed-rtos/rtos/Mutex.h@0:0ed2a7c7190c, 2013-05-31 (annotated)
- Committer:
- GordonSin
- Date:
- Fri May 31 04:09:54 2013 +0000
- Revision:
- 0:0ed2a7c7190c
31/5/2013;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GordonSin | 0:0ed2a7c7190c | 1 | /* Copyright (c) 2012 mbed.org */ |
GordonSin | 0:0ed2a7c7190c | 2 | #ifndef MUTEX_H |
GordonSin | 0:0ed2a7c7190c | 3 | #define MUTEX_H |
GordonSin | 0:0ed2a7c7190c | 4 | |
GordonSin | 0:0ed2a7c7190c | 5 | #include <stdint.h> |
GordonSin | 0:0ed2a7c7190c | 6 | #include "cmsis_os.h" |
GordonSin | 0:0ed2a7c7190c | 7 | |
GordonSin | 0:0ed2a7c7190c | 8 | namespace rtos { |
GordonSin | 0:0ed2a7c7190c | 9 | |
GordonSin | 0:0ed2a7c7190c | 10 | /*! The Mutex class is used to synchronise the execution of threads. |
GordonSin | 0:0ed2a7c7190c | 11 | This is for example used to protect access to a shared resource. |
GordonSin | 0:0ed2a7c7190c | 12 | */ |
GordonSin | 0:0ed2a7c7190c | 13 | class Mutex { |
GordonSin | 0:0ed2a7c7190c | 14 | public: |
GordonSin | 0:0ed2a7c7190c | 15 | /*! Create and Initialize a Mutex object */ |
GordonSin | 0:0ed2a7c7190c | 16 | Mutex(); |
GordonSin | 0:0ed2a7c7190c | 17 | |
GordonSin | 0:0ed2a7c7190c | 18 | /*! Wait until a Mutex becomes available. |
GordonSin | 0:0ed2a7c7190c | 19 | \param millisec timeout value or 0 in case of no time-out. (default: osWaitForever) |
GordonSin | 0:0ed2a7c7190c | 20 | \return status code that indicates the execution status of the function. |
GordonSin | 0:0ed2a7c7190c | 21 | */ |
GordonSin | 0:0ed2a7c7190c | 22 | osStatus lock(uint32_t millisec=osWaitForever); |
GordonSin | 0:0ed2a7c7190c | 23 | |
GordonSin | 0:0ed2a7c7190c | 24 | /*! Try to lock the mutex, and return immediately |
GordonSin | 0:0ed2a7c7190c | 25 | \return true if the mutex was acquired, false otherwise. |
GordonSin | 0:0ed2a7c7190c | 26 | */ |
GordonSin | 0:0ed2a7c7190c | 27 | bool trylock(); |
GordonSin | 0:0ed2a7c7190c | 28 | |
GordonSin | 0:0ed2a7c7190c | 29 | /*! Unlock the mutex that has previously been locked by the same thread |
GordonSin | 0:0ed2a7c7190c | 30 | \return status code that indicates the execution status of the function. |
GordonSin | 0:0ed2a7c7190c | 31 | */ |
GordonSin | 0:0ed2a7c7190c | 32 | osStatus unlock(); |
GordonSin | 0:0ed2a7c7190c | 33 | |
GordonSin | 0:0ed2a7c7190c | 34 | ~Mutex(); |
GordonSin | 0:0ed2a7c7190c | 35 | |
GordonSin | 0:0ed2a7c7190c | 36 | private: |
GordonSin | 0:0ed2a7c7190c | 37 | osMutexId _osMutexId; |
GordonSin | 0:0ed2a7c7190c | 38 | osMutexDef_t _osMutexDef; |
GordonSin | 0:0ed2a7c7190c | 39 | #ifdef CMSIS_OS_RTX |
GordonSin | 0:0ed2a7c7190c | 40 | int32_t _mutex_data[3]; |
GordonSin | 0:0ed2a7c7190c | 41 | #endif |
GordonSin | 0:0ed2a7c7190c | 42 | }; |
GordonSin | 0:0ed2a7c7190c | 43 | |
GordonSin | 0:0ed2a7c7190c | 44 | } |
GordonSin | 0:0ed2a7c7190c | 45 | #endif |