diff options
author | Owen Anderson <resistor@mac.com> | 2009-06-18 20:51:00 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-06-18 20:51:00 +0000 |
commit | a0ce1551db78754a44aa9c0872ed86736e831e24 (patch) | |
tree | 0e9b8dfb706921d584bcc73edad1e1eb5f5660b2 /include/llvm/System | |
parent | a2f7c0e76dabd5155062e6fb59c363de705afe00 (diff) | |
download | external_llvm-a0ce1551db78754a44aa9c0872ed86736e831e24.zip external_llvm-a0ce1551db78754a44aa9c0872ed86736e831e24.tar.gz external_llvm-a0ce1551db78754a44aa9c0872ed86736e831e24.tar.bz2 |
Add a SmartScopedLock, and use it to simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/System')
-rw-r--r-- | include/llvm/System/Mutex.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/System/Mutex.h b/include/llvm/System/Mutex.h index d8a1886..6f5614f 100644 --- a/include/llvm/System/Mutex.h +++ b/include/llvm/System/Mutex.h @@ -115,6 +115,22 @@ namespace llvm /// Mutex - A standard, always enforced mutex. typedef SmartMutex<false> Mutex; + + template<bool mt_only> + class SmartScopedLock { + SmartMutex<mt_only>* mtx; + + public: + SmartScopedLock(SmartMutex<mt_only>* m) : mtx(m) { + mtx->acquire(); + } + + ~SmartScopedLock() { + mtx->release(); + } + }; + + typedef SmartScopedLock<false> ScopedLock; } } |