memgraph/include/threading/sync/lockable.hpp

25 lines
412 B
C++
Raw Normal View History

#pragma once
#include <mutex>
#include "threading/sync/spinlock.hpp"
template <class lock_t = SpinLock>
class Lockable
{
public:
using lock_type = lock_t;
2015-11-09 02:05:34 +08:00
std::lock_guard<lock_t> acquire_guard() const
2015-10-04 15:47:15 +08:00
{
return std::lock_guard<lock_t>(lock);
}
2015-11-09 02:05:34 +08:00
std::unique_lock<lock_t> acquire_unique() const
{
return std::unique_lock<lock_t>(lock);
}
2015-11-09 02:05:34 +08:00
mutable lock_t lock;
};