1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/storage/table/segment_lock.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/constants.hpp"
12#include "duckdb/common/mutex.hpp"
13
14namespace duckdb {
15
16struct SegmentLock {
17public:
18 SegmentLock() {
19 }
20 SegmentLock(mutex &lock) : lock(lock) {
21 }
22 // disable copy constructors
23 SegmentLock(const SegmentLock &other) = delete;
24 SegmentLock &operator=(const SegmentLock &) = delete;
25 //! enable move constructors
26 SegmentLock(SegmentLock &&other) noexcept {
27 std::swap(x&: lock, y&: other.lock);
28 }
29 SegmentLock &operator=(SegmentLock &&other) noexcept {
30 std::swap(x&: lock, y&: other.lock);
31 return *this;
32 }
33
34private:
35 unique_lock<mutex> lock;
36};
37
38} // namespace duckdb
39