mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 04:22:03 +00:00
30 lines
846 B
C++
30 lines
846 B
C++
#pragma once
|
|
|
|
#include <Disks/IDisk.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class IDisk;
|
|
using DiskPtr = std::shared_ptr<IDisk>;
|
|
|
|
/// Helper class, that receives file descriptor and does fsync for it in destructor.
|
|
/// It's used to keep descriptor open, while doing some operations with it, and do fsync at the end.
|
|
/// Guaranties of sequence 'close-reopen-fsync' may depend on kernel version.
|
|
/// Source: linux-fsdevel mailing-list https://marc.info/?l=linux-fsdevel&m=152535409207496
|
|
class LocalDirectorySyncGuard final : public ISyncGuard
|
|
{
|
|
public:
|
|
/// NOTE: If you have already opened descriptor, it's preferred to use
|
|
/// this constructor instead of constructor with path.
|
|
LocalDirectorySyncGuard(int fd_) : fd(fd_) {}
|
|
LocalDirectorySyncGuard(const String & full_path);
|
|
~LocalDirectorySyncGuard() override;
|
|
|
|
private:
|
|
int fd = -1;
|
|
};
|
|
|
|
}
|
|
|