mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-12 05:58:15 -04:00
35 lines
807 B
C++
35 lines
807 B
C++
//=======================================================================
|
|
// Copyright Baptiste Wicht 2013-2018.
|
|
// Distributed under the terms of the MIT License.
|
|
// (See accompanying file LICENSE or copy at
|
|
// http://www.opensource.org/licenses/MIT)
|
|
//=======================================================================
|
|
|
|
#ifndef LOCK_GUARD_HPP
|
|
#define LOCK_GUARD_HPP
|
|
|
|
namespace std {
|
|
|
|
template<typename Lock>
|
|
struct lock_guard {
|
|
Lock& lock;
|
|
|
|
explicit lock_guard(Lock& l) : lock(l) {
|
|
lock.lock();
|
|
}
|
|
|
|
lock_guard(const lock_guard&) = delete;
|
|
lock_guard& operator=(const lock_guard&) = delete;
|
|
|
|
lock_guard(lock_guard&&) = delete;
|
|
lock_guard& operator=(const lock_guard&&) = delete;
|
|
|
|
~lock_guard(){
|
|
lock.unlock();
|
|
}
|
|
};
|
|
|
|
} //End of namespace std
|
|
|
|
#endif
|