Last active
December 20, 2015 00:49
-
-
Save ak110/6045063 to your computer and use it in GitHub Desktop.
std::lock_guard<std::mutex>の中で一時的にロックを解除したくなった時に作ったクラス。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <boost/noncopyable.hpp> | |
namespace { | |
/// 一時的にロックを解除するためのクラス | |
template<class Mutex> | |
class unlock_guard : private boost::noncopyable { | |
Mutex& m; | |
public: | |
typedef Mutex mutex_type; | |
/// unlock() | |
explicit unlock_guard(Mutex& m) : m(m) { m.unlock(); } | |
/// lock() | |
~unlock_guard() { m.lock(); } | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment