forked from scylladb/scylladb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_lock.hh
42 lines (32 loc) · 826 Bytes
/
file_lock.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Copyright (C) 2014-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#pragma once
#include <memory>
#include <filesystem>
#include <seastar/core/sstring.hh>
#include <seastar/core/future.hh>
#include "seastarx.hh"
namespace fs = std::filesystem;
namespace utils {
class file_lock {
public:
file_lock() = delete;
file_lock(const file_lock&) = delete;
file_lock(file_lock&&) noexcept;
~file_lock();
file_lock& operator=(file_lock&&) = default;
static future<file_lock> acquire(fs::path);
fs::path path() const;
sstring to_string() const {
return path().native();
}
private:
class impl;
file_lock(fs::path);
std::unique_ptr<impl> _impl;
};
}