Files
memgraph/include/threading/sync/lockable.hpp
sale 99b8a4f234 Added Skiplist ReverseIterator, Distance Approximation Prototype and documented some stuff
Summary: Skiplist ReverseIterator and Distance Approximation

Test Plan: manual

Reviewers: florijan, buda

Reviewed By: buda

Subscribers: pullbot, florijan, buda

Differential Revision: https://phabricator.memgraph.io/D44
2017-01-31 15:16:38 +01:00

32 lines
680 B
C++

#pragma once
#include <mutex>
#include "threading/sync/spinlock.hpp"
/**
* @class Lockable
*
* @brief
* Lockable is used as an custom implementation of a mutex mechanism. It is
* implemented as a wrapper around std::lock_guard and std::unique_guard with
* a default lock called Spinlock.
*
* @tparam lock_t type of lock to be used (default = Spinlock)
*/
template <class lock_t = SpinLock>
class Lockable {
public:
using lock_type = lock_t;
std::lock_guard<lock_t> acquire_guard() const {
return std::lock_guard<lock_t>(lock);
}
std::unique_lock<lock_t> acquire_unique() const {
return std::unique_lock<lock_t>(lock);
}
mutable lock_t lock;
};