mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Moved cpp code to src/cpp and js code to src/js.
This commit is contained in:
31
src/cpp/ripple/ScopedLock.h
Normal file
31
src/cpp/ripple/ScopedLock.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef __SCOPEDLOCKHOLDER__
|
||||
#define __SCOPEDLOCKHOLDER__
|
||||
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
// A lock holder that can be returned and copied by value
|
||||
// When the last reference goes away, the lock is released
|
||||
|
||||
class ScopedLock
|
||||
{
|
||||
protected:
|
||||
mutable boost::shared_ptr<boost::recursive_mutex::scoped_lock> mHolder;
|
||||
|
||||
public:
|
||||
ScopedLock(boost::recursive_mutex& mutex) :
|
||||
mHolder(boost::make_shared<boost::recursive_mutex::scoped_lock>(boost::ref(mutex)))
|
||||
{ ; }
|
||||
void lock() const
|
||||
{
|
||||
mHolder->lock();
|
||||
}
|
||||
void unlock() const
|
||||
{
|
||||
mHolder->unlock();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user