1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Simplify the SmartMutex implementation a bit.

llvm-svn: 73711
This commit is contained in:
Owen Anderson 2009-06-18 18:29:03 +00:00
parent 4760da0a7a
commit a1d2310ac7

View File

@ -86,31 +86,30 @@ namespace llvm
/// indicates whether this mutex should become a no-op when we're not /// indicates whether this mutex should become a no-op when we're not
/// running in multithreaded mode. /// running in multithreaded mode.
template<bool mt_only> template<bool mt_only>
class SmartMutex { class SmartMutex : public MutexImpl {
MutexImpl mtx;
public: public:
explicit SmartMutex(bool recursive = true) : mtx(recursive) { } explicit SmartMutex(bool recursive = true) : MutexImpl(recursive) { }
bool acquire() { bool acquire() {
if (!mt_only || (mt_only && llvm_is_multithreaded())) if (!mt_only && llvm_is_multithreaded())
return mtx.acquire(); return MutexImpl::acquire();
return true; return true;
} }
bool release() { bool release() {
if (!mt_only || (mt_only && llvm_is_multithreaded())) if (!mt_only || llvm_is_multithreaded())
return mtx.release(); return MutexImpl::release();
return true; return true;
} }
bool tryacquire() { bool tryacquire() {
if (!mt_only || (mt_only && llvm_is_multithreaded())) if (!mt_only || llvm_is_multithreaded())
return mtx.tryacquire(); return MutexImpl::tryacquire();
return true; return true;
} }
private: private:
SmartMutex<mt_only>(const SmartMutex<mt_only> & original); SmartMutex(const SmartMutex<mt_only> & original);
void operator=(const SmartMutex<mt_only> &); void operator=(const SmartMutex<mt_only> &);
}; };