mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Simplify the SmartMutex implementation a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73711 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b65e9ed106
commit
f0eeb9b7f5
@ -86,31 +86,30 @@ namespace llvm
|
||||
/// indicates whether this mutex should become a no-op when we're not
|
||||
/// running in multithreaded mode.
|
||||
template<bool mt_only>
|
||||
class SmartMutex {
|
||||
MutexImpl mtx;
|
||||
class SmartMutex : public MutexImpl {
|
||||
public:
|
||||
explicit SmartMutex(bool recursive = true) : mtx(recursive) { }
|
||||
explicit SmartMutex(bool recursive = true) : MutexImpl(recursive) { }
|
||||
|
||||
bool acquire() {
|
||||
if (!mt_only || (mt_only && llvm_is_multithreaded()))
|
||||
return mtx.acquire();
|
||||
if (!mt_only && llvm_is_multithreaded())
|
||||
return MutexImpl::acquire();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool release() {
|
||||
if (!mt_only || (mt_only && llvm_is_multithreaded()))
|
||||
return mtx.release();
|
||||
if (!mt_only || llvm_is_multithreaded())
|
||||
return MutexImpl::release();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tryacquire() {
|
||||
if (!mt_only || (mt_only && llvm_is_multithreaded()))
|
||||
return mtx.tryacquire();
|
||||
if (!mt_only || llvm_is_multithreaded())
|
||||
return MutexImpl::tryacquire();
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
SmartMutex<mt_only>(const SmartMutex<mt_only> & original);
|
||||
SmartMutex(const SmartMutex<mt_only> & original);
|
||||
void operator=(const SmartMutex<mt_only> &);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user