[DEV] add interface auto-remove Mutex

This commit is contained in:
Edouard DUPIN 2014-01-03 22:03:16 +01:00
parent 9c6c819288
commit 45602989a0
2 changed files with 24 additions and 1 deletions

View File

@ -1618,6 +1618,7 @@ template<class CLASS_TYPE> class RegExp {
*/
std::string getRegExDecorated(void) {
// TODO : do it...
return "";
}
private:
/**

View File

@ -52,7 +52,29 @@ namespace etk {
*/
void unLock(void);
};
/**
* @brief AutoLock and un-lock when exit fuction.
*/
class AutoLockMutex {
private:
// Keep a reference on the mutex
etk::Mutex &m_protect;
public:
/**
* @brief constructor that automaticly lock the mutex.
* @param[in] _protect Mutex to Lock.
*/
AutoLockMutex(etk::Mutex& _protect) :
m_protect(_protect) {
m_protect.lock();
}
/**
* @brief Destructor that Auto Unlock mutex when remove.
*/
virtual ~AutoLockMutex(void){
m_protect.unLock();
}
};
};
#endif