This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

71
thread/MONITOR.HPP Normal file
View File

@@ -0,0 +1,71 @@
#ifndef _THREAD_MONITOR_HPP_
#define _THREAD_MONITOR_HPP_
#ifndef _THREAD_MUTEX_HPP_
#include <thread/mutex.hpp>
#endif
template <class T>
class Monitor
{
public:
Monitor(void);
virtual ~Monitor();
void enter(void);
void leave(void);
T *operator->(void);
operator T*(void);
Monitor &operator=(T *pObj);
private:
T *mlpObj;
Mutex mMutex;
};
template <class T>
inline
Monitor<T>::Monitor(void)
: mlpObj(0)
{
}
template <class T>
inline
Monitor<T>::~Monitor()
{
}
template <class T>
inline
T *Monitor<T>::operator->(void)
{
return mlpObj;
}
template <class T>
inline
Monitor<T>::operator T*(void)
{
return mlpObj;
}
template <class T>
inline
Monitor<T> &Monitor<T>::operator=(T *pObj)
{
mlpObj=pObj;
return *this;
}
template <class T>
inline
void Monitor<T>::enter(void)
{
mMutex.requestMutex();
}
template <class T>
inline
void Monitor<T>::leave(void)
{
mMutex.releaseMutex();
}
#endif