1 /* 2 * Copyright (C) 2015-2017 Alibaba Group Holding Limited 3 */ 4 5 #include <stdint.h> 6 #include <k_api.h> 7 8 /** @defgroup cpp_aos_api cplusplus 9 * @ingroup aos_components 10 * @{ 11 */ 12 13 /** 14 * @} 15 */ 16 17 /** @defgroup cpp_aos_mutex 18 * @ingroup cpp_aos_api 19 * @{ 20 */ 21 namespace AOS { 22 23 #define Mutex_WAIT_FOREVER 0xFFFFFFFFU 24 25 /** 26 * @brief Mutex Class. 27 * 28 */ 29 30 class Mutex 31 { 32 public: 33 /** 34 * @brief This function will create a mutex 35 * @param[in] name name of the mutex 36 * @return the operation status, RHINO_SUCCESS is OK, others is error 37 */ 38 kstat_t create(const name_t *name); 39 40 /** 41 * @brief This function will delete a mutex 42 * @param[in] NULL 43 * @return the operation status, RHINO_SUCCESS is OK, others is error 44 */ 45 kstat_t destroy(void); 46 47 /** 48 * @brief This function will lock mutex 49 * @param[in] millisec millisec to be wait for before lock 50 * @return the operation status, RHINO_SUCCESS is OK, others is error 51 */ 52 kstat_t lock(uint32_t millisec); 53 54 /** 55 * @brief This function will unlock a mutex 56 * @param[in] NULL 57 * @return the operation status, RHINO_SUCCESS is OK, others is error 58 */ 59 kstat_t unlock(void); 60 61 /** 62 * @brief This function will get a Mutex struct pointer 63 * @param[in] none 64 * @return Mutex struct pointer 65 */ 66 kmutex_t *self(void); 67 68 private: 69 /** 70 * @brief a Queue buffer 71 */ 72 kmutex_t _mutex_def; 73 }; 74 75 } 76 /** 77 * @} 78 */ 79